带有AND& amp;的弹性查询BOOL要么

时间:2017-05-17 19:28:36

标签: elasticsearch lucene

我是Elastic的新手。我试图在sql中做一个简单的查询:

Select * from [movies] where is_adult = false AND (movie_title like '%xxx%' OR genre = 'xxxx')

在弹性中,我能走得更近:

GET /idxsearch/movies/_search
{
  "size": 10,
  "query": {
    "bool": {
       "filter": {
        "term": {
          "is_adult": false
        }
      },
      "must": [
        {
          "multi_match": {
            "query": "xxx",
            "operator": "and",
            "fields": [ "movie_title.default^5", "movie_title.shingles" ]
          }
        }
      ],
      "should": [
        {"term": {
          "genre.name": {
            "value": "xxxx"
          }
        }}
      ]
    }
  }
}

但是用一些数据来测试这个查询,我看到它不起作用....

欢呼声

只是为了检查,这是自定义分析器的一部分:

"shingle_analyzer": {
    "type": "custom",
    "tokenizer": "standard",
    "filter": ["lowercase", "asciifolding", "shingle_filter"]
}

"shingle_filter": {
  "type": "shingle",
  "min_shingle_size": 2,
  "max_shingle_size": 2
}

"match_title":  {
"type": "text",
"fields": {
    "default":  {"type": "text", "analyzer": "default_analyzer" },
    "snowball": {"type": "text", "analyzer": "snowball_analyzer"},
    "shingles": {"type": "text", "analyzer": "shingle_analyzer" },
    "ngrams":   {"type": "text", "analyzer": "edgengram_analyzer", 
                    "search_analyzer": "default_analyzer"}
}

0 个答案:

没有答案