elasticsearch - 从自定义FieldBridge索引LongField问题

标签 elasticsearch lucene field

为了使用lucene进行搜索,我架了一座桥,

public class EntityIDFieldBridge implements FieldBridge {
    @Override
    public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
        BaseEntity baseEntity = (BaseEntity) value;
        if(value !=null){
            Field field = new LongField(name, baseEntity.getId(),Field.Store.NO);
            document.add(field);
        }
    }
}

当我寻找值(value)时,我没有得到正确的文件。当我搜索术语:*时,我确实得到了不为null的那些,因此我看到它被索引了……StringField正常工作。但是我认为这应该是一个漫长的 Realm 。有任何想法吗?

最佳答案

根据您提供的少量信息,我假设您不是要获取值null

Field Bridge提供了有关它是什么,lucene支持什么以及如何工作的更多信息:

In Lucene all index fields have to be represented as Strings. For this reason all entity properties annotated with @Field have to be indexed in a String form. For most of your properties, Hibernate Search does the translation job for you thanks to a built-in set of bridges. In some cases, though you need a more fine grain control over the translation process.



也适用于Null值

null elements are not indexed. Lucene does not support null elements and this does not make much sense either.

关于elasticsearch - 从自定义FieldBridge索引LongField问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62191290/

相关文章:

XML 格式的 solr 原子更新

php - 如何将自定义字段添加到编辑订单页面

Elasticsearch 返回总计 624,但 hits 数组为空

ElasticSearch 高亮显示错误的字段

sql-server - 使用 Lucene 作为 Dbms

text - UITextField - 多行

java - 数组列表中的对象不断替换?

elasticsearch - 将MariaDB中的多个表同步到Elasticsearch 7.5

elasticsearch - 如何在elasticsearch中删除以前索引的文档?

php - zend 搜索 lucene 查询 api : boosting a term