elasticsearch tf-idf并忽略搜索中的字段长度范数 [英] elasticsearch tf-idf and ignoring field length norm in search

查看:63
本文介绍了elasticsearch tf-idf并忽略搜索中的字段长度范数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在elasticsearch中执行搜索,而忽略tf-idf搜索中的字段范数.您可以通过通过设置索引映射忽略字段规范来完成此操作.但是,这似乎是通过更改索引来完成的,我只想修改搜索(我需要其他类型搜索的规范).做到这一点的最佳方法是什么?我正在使用elasticsearch.js作为Elasticsearch的界面.

I would like to perform searches in elasticsearch ignoring the field-norm in the tf-idf search. You can accomplish this by ignoring the field norms by setting the index mappings. However it seems that this is accomplished by changes to the indexing, I just want to modify the search (I need the norms for other types of searches). What is the best way to accomplish this? I'm using elasticsearch.js as my interface to elasticsearch.

推荐答案

您不能基于每次搜索禁用规范,但可以使用

You can't disable norms on a per-search basis, but you can use the Multi Fields API to add an additional field where the norms are disabled.

PUT /my_index
{
  "mappings": {
    "my_type": {
      "properties": {
        "my_field": {
          "type": "string",
          "fields": {
            "no_norms": { 
              "type":  "string",
              "norms": {
                "enabled": false
              }
            }
          }
        }
      }
    }
  }
}

现在,如果您需要规范,则可以在 my_field 上进行搜索;如果不需要,则可以在 my_field.no_norms 中进行搜索.您必须重新索引数据,以便新字段可用于所有文档,只是将其添加到映射中不会更改退出文档的任何内容.

Now you can search on my_field if you need norms and on my_field.no_norms if you don't. You have to reindex the data in order for the new field to be available for all documents, just adding it to the mapping won't change anything for exiting docs.

这篇关于elasticsearch tf-idf并忽略搜索中的字段长度范数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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