elasticsearch 更新;关键词";至;“文本”;elasticsearch中不精确词匹配索引的字段类型,elasticsearch,lucene,elasticsearch,Lucene" /> elasticsearch 更新;关键词";至;“文本”;elasticsearch中不精确词匹配索引的字段类型,elasticsearch,lucene,elasticsearch,Lucene" />

elasticsearch 更新;关键词";至;“文本”;elasticsearch中不精确词匹配索引的字段类型

elasticsearch 更新;关键词";至;“文本”;elasticsearch中不精确词匹配索引的字段类型,elasticsearch,lucene,elasticsearch,Lucene,我试图通过在索引上使用下面的PUT请求进行更新,但仍然得到上面的_映射输出 { "myindex": { "mappings": { "properties": { "city": { "type": "text",

我试图通过在索引上使用下面的PUT请求进行更新,但仍然得到上面的_映射输出

{
        "myindex": {
            "mappings": {
                "properties": {
                    "city": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    }
                }
            }
        }
    }
我不能用不精确的词进行查询,因为它的类型是“关键字”,因为下面记录中的实际值是“孟买”


最小值应匹配

必须与要返回的文档匹配的最小子句数

它表示子句的百分比,而不是字符串的百分比。浏览文档,构建查询框架,以获得预期结果。无效查询返回无效结果。

下面的映射(问题中共享的内容)将“city”存储为文本,“city.keyword”存储为关键字

{
    "query": {
        "bool": {
            "must": {
                "match": {
                    "city": {
                        "query": "Mumbi",
                        "minimum_should_match": "10%"
                    }
                }
            }
        }
    }
}
您的是模糊搜索的用例,而不是最小匹配

ES文档用于模糊搜索:

尝试下面的查询

{
        "myindex": {
            "mappings": {
                "properties": {
                    "city": {
                        "type": "text",   // ==========> Store city as text
                        "fields": {
                            "keyword": {
                                "type": "keyword",  // =========> store city.keyword as a keyword
                                "ignore_above": 256
                            }
                        }
                    }
                }
            }
        }
    }

根据您共享的映射,“城市”将同时存储为“文本”和“关键字”city'是文本表示法,city.keyword是关键字表示法。@SahilGupta那么为什么上面的查询不返回记录?您打算使用模糊搜索。。。。使用“fuzzness”代替minimum_-shoul_-match:@SahilGupta我尝试了“fuzzy”:{“city”:“Mumbi”},但它不返回值..但我想使用minimum_-should_-match..这样我就可以基于%进行匹配..就像它匹配了80%,然后返回记录读取&您尝试的模糊查询不起作用,因为在分析之前不会分析搜索文本,因此,在这种情况下,即使是案例规范化也不会发生。
{
        "myindex": {
            "mappings": {
                "properties": {
                    "city": {
                        "type": "text",   // ==========> Store city as text
                        "fields": {
                            "keyword": {
                                "type": "keyword",  // =========> store city.keyword as a keyword
                                "ignore_above": 256
                            }
                        }
                    }
                }
            }
        }
    }
{
  "query": {
    "match": {
      "city": {
        "query": "mubai",
        "fuzziness": "AUTO"
       }
     }
   }
}