简体   繁体   English

Lucene:IndexWriter.update-如何形成用于搜索数值的术语

[英]Lucene : IndexWriter.update - how to form term for searching numeric values

My index has the following fields : ID (type long, indexed, stored, not analyzed), Contents (String, not indexed, not analyzed, stored) and Tags (String, indexed, analyzed, stored). 我的索引具有以下字段:ID(类型long,已索引,存储,未分析),内容(字符串,未索引,未分析,已存储)和标签(String,已索引,分析,已存储)。

Need to update the Contents for a given ID - how to do that using IndexWriter.update? 需要更新给定ID的内容-如何使用IndexWriter.update做到这一点? How do I form the term? 我如何形成这个词?

If the ID is stored as String I can form the Term as new Term(ID, "someID") - but will that have any other impact regarding long/String conversions etc.? 如果ID以字符串形式存储,那么我可以将Term形成为新的Term(ID,“ someID”)-但这会对长/字符串转换等产生其他影响吗?

Assuming your ID is a numeric field, then have a look at the "longToPrefixCoded" function in the "NumericUtils" namespace. 假设您的ID是一个数字字段,然后查看“ NumericUtils”命名空间中的“ longToPrefixCoded”函数。

Hope this helps, 希望这可以帮助,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM