ES中有多个字段的通配符查询?

ama*_*rma 3 elasticsearch

任何人都可以请告诉我如何在elasticsearch中编写带有多个字段的通配符查询我已经搜索了很多但是有些人告诉我使用查询字符串或多个匹配但我的情况下的问题是查询字符串对我不起作用我的如果有人对此有任何了解,请在下面给出单个字段通配符查询的代码,请分享一下

"query": {
      "wildcard" : { "places_area1.city.raw_wildcard" : last_wildcard_string }
 }
Run Code Online (Sandbox Code Playgroud)

更新 映射

"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"
              }
            } },
          }
        }
      }
    }
Run Code Online (Sandbox Code Playgroud)

先感谢您

Chi*_*h25 7

你在找这样的东西吗?

{
  "query": {
    "query_string": {
      "fields": ["title", "description", "state"], 
      "query": "Ban*",
      "lowercase_expanded_terms": false
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

你为什么需要"lowercase_expanded_terms": false

由于你正在使用keywordwhitespace标记器,班加罗尔一词被归类为班加罗尔,而使用的query string wildcard Ban*是较低的,因为它是默认设置,ES正在寻找以禁令开头的单词,因此它找不到班加罗尔.你也可以通过添加lowercase过滤器来解决这个问题mappings

它之前也有用,因为你没有指定任何analzyer,默认情况下ES使用standard analzyer它在内部使用lowercase token filter