开发者

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

开发者 https://www.devze.com 2023-02-09 08:30 出处:网络
Suppose I add several values to a Document under the same field name: doc.Add( new Field( \"tag\", \"one\" ) );

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" );


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

I wouldn't depend on it.

0

精彩评论

暂无评论...
验证码 换一张
取 消