elasticsearch匹配查询不适用于数字

时间:2017-08-21 10:48:47

标签: elasticsearch

我有一个搜索查询,用于搜索报告名称。 我已使用autocomplete,edge_ngram索引字段名称 正常字段名称搜索是正确的,当我在字段名称中有一个数字/年它不起作用。 查询:

{
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "should": [
            {
              "match": {
                "field_name": {
                  "query": "hybrid seeds india 2017",
                  "operator": "and"
                }
              }
            }
          ]
        }
      }
    }
  },
  "from": 0,
  "size": 10
}

设置和映射

{
"mappings": {
    "pages": {
        "properties": {     
            "report_name": {
                "fields": {
                    "autocomplete": {
                        "search_analyzer": "report_name_search",
                        "analyzer": "report_name_index",
                        "type": "string"
                    },
                    "report_name": {
                        "index": "not_analyzed",
                        "type": "string"
                    }
                },
                "type": "multi_field"
            }               
        }
    }
},
"settings": {

    "analysis": {
        "filter": {
            "report_name_ngram": {
                "max_gram": 150,
                "min_gram": 2,
                "type": "edge_ngram"
            }
        },
        "analyzer": {               
            "report_name_index": {
                "filter": [
                    "lowercase",
                    "report_name_ngram"
                ],
                "tokenizer": "keyword"
            },
            "report_name_search": {
                "filter": [
                    "lowercase"
                ],
                "tokenizer": "keyword"
            }
        }
    }
}

}

你能帮助我吗?

提前致谢

0 个答案:

没有答案