IntPoint未对整数值编制索引 [英] IntPoint is not indexing integer values

查看:376
本文介绍了IntPoint未对整数值编制索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我们尝试使用字段类型IntPoint索引整数值,但这些值似乎没有正确传输到我们的Lucene索引中。

While we're trying to index integer values with the Field Type "IntPoint", the values seem to be not transferred correctly into our Lucene Index.

我们是使用Lucene 6.0。

We are working with Lucene 6.0.

根据Lucene文档的代码片段:

According to the Lucene documention the code snippet:

        doc.add(new IntPoint(LENGTH2, 17));

应将值为17的LENGTH2文档字段添加到可索引文档中。
不幸的是,我们的索引字段LENGHT2中没有值。

should add the LENGTH2 document field with the Value "17" to our indexable document. Unfortunately, there are no values in our index field LENGHT2.

我们还尝试使用不推荐使用的字段类型LegacyIntField。有了这个类型,我们在索引字段中得到了一些神秘的smybols,如:

We also tried this with the deprecated Field Type "LegacyIntField". With this Type we got some cryptic smybols in our index field like:

        950 length  h(5j
        950 length  pT
        950 length  xj
        950 length  `PkU2

对于这种类型我们使用了以下代码:

For this type we used the following code:

        LegacyIntField intField = new LegacyIntField(LENGTH,0,Field.Store.NO);
        intField.setIntValue(17);
        doc.add(intField);

你知道一个解决方案吗?对于这个问题?

Do you know a solution for this problem?

加法:
你有一个有效的例子,其中包括IntPoint的索引和搜索吗?
我们试了一下,但似乎无法正常工作。
Lucene的Java代码IntPoint索引

我们也尝试在这个领域进行一些搜索。但结果与我们的预期不符。

We also tried to do some search on this field. But the results didn't match with that what we expected.

   QueryParser parser = new MultiFieldQueryParser(fields,analyzer);
   Query query = parser.parse("content:" + queryString);

   Query queryNumeric = IntPoint.newRangeQuery(Indexer.LENGTH2, 0, 5);
   Builder builder = new Builder();
   builder.add(query, Occur.MUST);
   builder.add(queryNumeric, Occur.MUST);
   BooleanQuery booleanQ = builder.build();

   TopDocs hits2 = is.search(booleanQ, 1000);
   System.out.print("short: " + hits2.totalHits);


推荐答案

除此之外,您将索引字段为:

Besides that you're indexing field as:

doc.add(new IntPoint(LENGTH2,17));

您还需要通过添加 StoredField的单独实例来单独存储该字段

doc.add(new StoredField(LENGTH2,17));

根据 IntPoint的文档


快速范围过滤器的索引int字段。如果您还需要存储该值,则应添加单独的StoredField实例。

An indexed int field for fast range filters. If you also need to store the value, you should add a separate StoredField instance.

参考:
https://lucene.apache.org/core/6_1_0/core /org/apache/lucene/document/IntPoint.html

这篇关于IntPoint未对整数值编制索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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