代码之家  ›  专栏  ›  技术社区  ›  italktothewind

弹性搜索-更像是返回空结果的查询

  •  1
  • italktothewind  · 技术社区  · 7 年前

    我正在使用弹性搜索来创建某种标签引擎。我正在插入文档,无法检索它。我复制问题的步骤:

    PUT index
    {
    "mappings": {
        "taggeable" : {
            "_all" : {"enabled" : false},
            "properties" : {
                "id" : {
                    "type" : "string",
                    "index" : "no"
                },
                "tags" : {
                      "type" : "text"
                }
                }
            }
        }
    }
    

    2) 插入文档:

    POST index/taggeable
    {
    "id" : "1",
    "tags" : "tag1 tag2"
    }
    

    3) 使用类似以下内容的查询:

    GET index/_search
    {
    "query": {
        "more_like_this" : {
            "fields" : ["tags"],
            "like" : ["tag1"],
            "min_term_freq" : 1
        }
    }
    }
    

    但我收到:

    {
    "_shards": {
        "failed": 0, 
        "skipped": 0, 
        "successful": 5, 
        "total": 5
    }, 
    "hits": {
        "hits": [], 
        "max_score": null, 
        "total": 0
    }, 
    "timed_out": false, 
    "took": 1
    }
    

    有人知道我做错了什么吗?我应该检索我插入的文档。

    1 回复  |  直到 7 年前
        1
  •  1
  •   Mysterion    7 年前

    您设置了参数

    最小项频率

    从中忽略项的最小项频率 输入文档。默认为2。

    min\u doc\u freq

    忽略条款的最低文档频率

    在您的情况下,如果您只有一个文档,则将忽略该文档,因此您需要添加更多文档,或者指定参数 min_doc_freq 至1

    推荐文章