繁体   English   中英

ElasticSearch“更像这样”返回空结果

[英]ElasticSearch "more like this" returning empty result

我做了一个非常简单的测试来找出我的错误,但没有找到。 我创建了两个索引,我试图在ppa索引中搜索与ods索引中的给定文档类似的文档(就像这里的第二个例子https://www.elastic.co/guide/en/elasticsearch/reference /current/query-dsl-mlt-query.html )。

这些是我对 ppa 索引的设置、映射和文档:

PUT /ppa
{
  "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 0,
      "analysis": {
          "filter": {
              "brazilian_stop": {
                  "type": "stop",
                  "stopwords": "_brazilian_"
              },
              "brazilian_stemmer": {
                  "type": "stemmer",
                  "language": "brazilian"
              }
          },
          "analyzer": {
              "brazilian": {
                  "tokenizer": "standard",
                  "filter": [
                      "lowercase",
                      "brazilian_stop",
                      "brazilian_stemmer"
                  ]
              }
          }
      }
  }
}

PUT /ppa/_mapping/ppa
{"properties": {"descricao": {"type": "text", "analyzer": "brazilian"}}}

POST /_bulk
{"index":{"_index":"ppa","_type":"ppa"}}
{"descricao": "erradicar a pobreza"}
{"index":{"_index":"ppa","_type":"ppa"}}
{"descricao": "erradicar a pobreza"}

这些是我的 ods 索引设置、映射和文档:

PUT /ods
{
  "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 0,
      "analysis": {
          "filter": {
              "brazilian_stop": {
                  "type": "stop",
                  "stopwords": "_brazilian_"
              },
              "brazilian_stemmer": {
                  "type": "stemmer",
                  "language": "brazilian"
              }
          },
          "analyzer": {
              "brazilian": {
                  "tokenizer": "standard",
                  "filter": [
                      "lowercase",
                      "brazilian_stop",
                      "brazilian_stemmer"
                  ]
              }
          }
      }
  }
}

PUT /ods/_mapping/ods
{"properties": {"metaodsdescricao": {"type": "text", "analyzer": "brazilian"},"metaodsid": {"type": "integer"}}}

POST /_bulk
{"index":{"_index":"ods","_type":"ods", "_id" : "1" }}
{ "metaodsdescricao": "erradicar a pobreza","metaodsid": 1}
{"index":{"_index":"ods","_type":"ods", "_id" : "2" }}
{"metaodsdescricao": "crianças que vivem na pobreza", "metaodsid": 2}

现在,此搜索不起作用:

GET /ppa/ppa/_search
{
    "query": {
        "more_like_this" : {
            "fields" : ["descricao"],
            "like" : [
            {
                "_index" : "ods",
                "_type" : "ods",
                "_id" : "1"
            }
            ],
            "min_term_freq" : 1,
            "min_doc_freq" : 1,
            "max_query_terms" : 20
        }
    }
}

但这个确实有效:

GET /ppa/ppa/_search
{
    "query": {
        "more_like_this" : {
            "fields" : ["descricao"],
            "like" : ["erradicar a pobreza"],
            "min_term_freq" : 1,
            "min_doc_freq" : 1,
            "max_query_terms" : 20
        }
    }
}

怎么了? 请帮我把这个返回空以外的东西。

当您为大量数据建立索引时,“more like this”查询效果很好。 空结果可能是弹性索引中存在的文档很少的征兆。

暂无
暂无

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

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