2016-10-25 7 views
0

これはマッピングです。elasticsearchのインデックスフィールドでクエリを使用しない方法

curl -XPUT 'localhost:9200/products/' -d '{ 
    "settings" : { 
     "index" : { 
      "number_of_shards" : 6, 
      "number_of_replicas" : 1 
     } 
    }, 
    "mappings" : { 
     "product" : { 
      "_all":{ "enabled": true }, 
      "properties":{ 
      "id" : { "type" : "string", "index" : "not_analyzed", "include_in_all": true }, 
      "description" : { "type" : "string" }, 
      "title" : { "type" : "string", "boost" : 2 }, 
     } 
     } 
    } 
}' 

私は説明がない広告を受け取りたくありません。しかしあなたがマッピングで見ることができるように "記述"はインデックスを持っています。 したがって、説明ではクエリを使用しないでください。 私を助けてください。

私はelasticsearchの文書を見ましたが、私はこのクエリを使用します。

**query => { 
    filtered => { 
     filter => { 
      not => { 
       filter => { 
        term => {description => ''} 
       } 
      } 
     }, 
     query => { 
      match => { _all => $q } 
     } 
    } 
}** 

しかし、それは機能していない、私は説明にはインデックスが適切だと思いますか?あなたはis what you have as filter. The approach you used with filtered`はES 2.xので廃止されたクエリとfilter as filter. What's inside of必見is what you have as query and what's inside ofフィルタとしてmustboolを持って

{ 
    "query": { 
    "bool": { 
     "must": [ 
     {"match_all": {}} 
     ], 
     "filter": { 
     "bool": { 
      "must": [ 
      { 
       "exists": { 
       "field": "description" 
       } 
      }, 
      { 
       "wildcard": { 
       "description": "*" 
       } 
      } 
      ] 
     } 
     } 
    } 
    } 
} 

代わりのfiltered

+0

どのESバージョンですか? –

+0

ESバージョン:2.4 – Ganesh

答えて

2

2.4については、これは正しい構文とクエリのアプローチになります

関連する問題