Query_string在Elasticsearch中没有返回任何内容?

时间:2015-11-20 18:26:15

标签: elasticsearch

Hello All我遇到了一个问题,当我使用query_string和下面给出的映射时,一切正常,我只是使用没有过滤器的默认分析器。

mappings : {
    places_area1: {
      properties:{
        area1         : {"type" : "string", "index": "analyzed"},
        city         : {"type" : "string", "index": "analyzed"}
        },
      }
    }
  }
}

但是现在当我试图将query_string用于这个映射它不起作用时,有人可以告诉我我做错了什么,我猜它是因为空白标记符,但为什么。

"settings": {
    "index": {
      "analysis": {
        "analyzer": {
          "synonym_wildcard": {
            "tokenizer": "whitespace",
            "filter": ["filter_wildcard"]
          },
          "synonym_term": {
            "tokenizer": "keyword",
            "filter": ["filter_term"]
          },
          "simple_wildcard": {
            "tokenizer": "whitespace"
          }
        },
        "filter": {
          "filter_term": {
            "tokenizer": "keyword", // here you have to write this only for tokenizer keyword but not for whitespace
            "type": "synonym",
            "synonyms_path": "synonyms.txt",
          },
          "filter_wildcard": {
            "type": "synonym",
            "synonyms_path": "synonyms.txt",
          }
        }
      }
    }
  },
  mappings : {
    places_area1: {
      properties:{
        area1         : {"type" : "string", "index": "analyzed", "analyzer": "simple_wildcard"},
        city         : {"type" : "string", "fields": {
          "raw": {
            "type": "string",
            "analyzer": "synonym_term"
          },
          "raw_wildcard": {
            "type": "string",
            "analyzer": "synonym_wildcard"
          }
        } },
      }
    }
  }
}

1 个答案:

答案 0 :(得分:1)

我认为问题可能是您的查询是小写的,因为默认情况下"lowercase_expanded_terms"是真的

 {
      "query": {
        "query_string": {
          "default_field": "state",
          "query": "Ban*",
          "lowercase_expanded_terms": false
        }
      }
    }

现在这应该与班加罗尔相匹配