【问题标题】:Lucene not returning offsets for complex queriesLucene 不返回复杂查询的偏移量
【发布时间】:2012-08-31 21:06:33
【问题描述】:

我正在使用 Lucene 在我的 android 应用程序中进行搜索,但是当我运行复杂查询时,它不会返回术语的偏移量。

例如:

+content:"word" +(personid:NULL personid:123)
+content:"word" +(personid:NULL)
+content:"word" -personid:123

不会为“单词”返回任何偏移量。

+content:word

将返回偏移量。

这是我在每个字段中存储的内容

 doc.add(new Field(PERSON_ID_FIELD, request.getPersonId(), Field.Store.YES, Field.Index.NOT_ANALYZED));
 // we don't actually store the content here
 doc.add(new Field(CONTENT_FIELD, request.getContent(), Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_OFFSETS));

我错过了什么吗?我需要在查询中做些什么来获取偏移量吗?

谢谢。

【问题讨论】:

  • 您如何尝试检索偏移量?
  • 我正在获取内容归档的 TermVector,然后询问查询中每个术语的偏移量。
  • @jpountz 谢谢我需要的问题。

标签: lucene


【解决方案1】:

如果尝试使用personid 从术语的内容字段中获取偏移量,它不会返回任何偏移量。然后,通过不遍历查询中的整个术语列表,永远不会到达查询的内容术语。因此不会返回任何偏移量。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-11
    • 1970-01-01
    • 2015-08-08
    • 1970-01-01
    • 2021-01-29
    • 2012-05-30
    • 2020-03-13
    • 2019-05-30
    相关资源
    最近更新 更多