1
我正在尝试使用elasticsearch来增强用Lucene实现的图像搜索项目。我很难找到一种方法来配置elasticsearch,使索引字段具有Lucene IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS
。在elasticsearch中,如何使索引字段具有lucene IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS?
工作的Lucene索引代码是:
Document doc = new Document();
FieldType myFieldType = new FieldType();
myFieldType.setIndexed(true);
myFieldType.setOmitNorms(true);
myFieldType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS); // tell indexer to store image token's positions, offsets, and payloads
myFieldType.setStored(false);
myFieldType.setTokenized(true);
myFieldType.freeze();
doc.add(new Field("tokens", tokenStream_w_payload, myFieldType));
indexWriter.addDocument(doc);
我没有问题使我的分析,我的查询处理程序elasticsearch插件,但使用默认elasticsearch设置,我不能得到任何信息的位置,偏移和来自Lucene TermsEnum
和DocsAndPositionsEnum
对象的有效载荷从我可以在其中看到的标记索引的AtomicReaderContext
初始化。
我正在关注elasticsearch文档并使用各种建议值与字段映射设置“index_options”一起玩: –
我正在关注elasticsearch菜单https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping- core-types.html并使用各种建议值与字段映射设置“index_options”一起播放。 它没有帮助。例如, 卷曲-s -XPUT的 'http://本地主机:9200 /测试/' -D“{ “映射”:{ “测试”:{ “属性”:{ “令牌”:{ “类型”: “串”, “索引”: “分析”, “存储”: “是”, “term_vector”: “with_positions_offsets_payloads”, “index_options”: “偏移” } } } } }' –