Is the order of multi-valued fields in Lucene stable?

一曲冷凌霜 提交于 2019-12-23 01:43:24

问题


Suppose I add several values to a Document under the same field name:

doc.Add( new Field( "tag", "one" ) );
doc.Add( new Field( "tag", "two" ) );
doc.Add( new Field( "tag", "three" ) );
doc.Add( new Field( "tag", "four" ) );

If I then later retrieve these fields from a new instance of Document (from a search result), am I guaranteed that the order of the Fields in the array will remain the same?

Field[] fields = doc.GetFields( "tag" );

Debug.Assert( fields[0].StringValue() == "one" );
Debug.Assert( fields[1].StringValue() == "two" );
Debug.Assert( fields[2].StringValue() == "three" );
Debug.Assert( fields[3].StringValue() == "four" );

回答1:


Current code does, but states no guarantees whatsoever, so it may change at any time.

I wouldn't depend on it.



来源:https://stackoverflow.com/questions/4951215/is-the-order-of-multi-valued-fields-in-lucene-stable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!