Lucene中多值字段的顺序是否稳定? [英] Is the order of multi-valued fields in Lucene stable?

查看:57
本文介绍了Lucene中多值字段的顺序是否稳定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我将几个值添加到同一字段名称下的Document:

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

如果以后再从新的Document实例(从搜索结果)中检索这些字段,是否可以保证数组中Field的顺序保持不变?

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.

我不会依赖它.

这篇关于Lucene中多值字段的顺序是否稳定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆