2017-02-17 4 views
0

AWS上で実行される弾性1.5。次のクエリを実行しようとしています。分析されないフィールドのワイルドカードクエリは結果を返しません。

GET /pictures_testing/_search 
{ 
    "query": { 
     "filtered": { 
     "query": { 
      "wildcard": { 
       "aircraft_type_search.search": { 
        "wildcard": "piper" 
       } 
      } 
     } 
     } 
    } 
} 

結果は返されません。 (

私は他の分野と同じように設定していると.searchマッピングが返されます
{ 
    "pictures_testing": { 
     "mappings": { 
     "picture": { 
      "aircraft_type_search": { 
       "full_name": "aircraft_type_search", 
       "mapping": { 
        "aircraft_type_search": { 
        "type": "string", 
        "fields": { 
         "lower_case_sort": { 
          "type": "string", 
          "analyzer": "case_insensitive_sort" 
         }, 
         "search": { 
          "type": "string", 
          "index": "not_analyzed" 
         } 
        } 
        } 
       } 
      } 
     } 
     } 
    } 
} 

結果:しかし、私はマッピングここ

だフィールドマッピングだけaircraft_type_search.searchない、バックaircraft_type_searchからの結果を得ることができます究極のポイントであるワイルドカードクエリを含む)ので、私はこのフィールドがなぜそうでないのかについて少し損失があります。

GET/pictures_testing /リターン:一致している必要があります

{ 
    "pictures_testing": { 
     "aliases": {}, 
     "mappings": { 
     "picture": { 
      "properties": { 
       "ab_archive": { 
        "type": "string" 
       }, 
       "ab_publication": { 
        "type": "string" 
       }, 
       "aircraft_id": { 
        "type": "integer", 
        "ignore_malformed": true, 
        "null_value": -1 
       }, 
       "aircraft_type": { 
        "type": "string" 
       }, 
       "aircraft_type_search": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "aircraft_verified": { 
        "type": "string" 
       }, 
       "airport": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "airshow": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "airshow_id": { 
        "type": "integer", 
        "ignore_malformed": true, 
        "null_value": -1 
       }, 
       "airshow_verified": { 
        "type": "string" 
       }, 
       "approved": { 
        "type": "integer", 
        "ignore_malformed": true 
       }, 
       "category": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "code_number": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "construction_number": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "country": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "created_by": { 
        "type": "string" 
       }, 
       "created_on": { 
        "type": "string" 
       }, 
       "date_added": { 
        "type": "date", 
        "ignore_malformed": true, 
        "format": "yyyy-MM-dd HH:mm:ss" 
       }, 
       "date_approved": { 
        "type": "date", 
        "ignore_malformed": true, 
        "format": "yyyy-MM-dd HH:mm:ss" 
       }, 
       "date_taken": { 
        "type": "string" 
       }, 
       "date_taken_formatted": { 
        "type": "date", 
        "ignore_malformed": true, 
        "format": "yyyy-MM-dd HH:mm:ss" 
       }, 
       "display_picture": { 
        "type": "string" 
       }, 
       "displayed_info": { 
        "type": "string" 
       }, 
       "displayteam": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "displayteam_id": { 
        "type": "integer", 
        "ignore_malformed": true, 
        "null_value": -1 
       }, 
       "displayteam_verified": { 
        "type": "string" 
       }, 
       "editors_choice": { 
        "type": "string" 
       }, 
       "email": { 
        "type": "string" 
       }, 
       "filename": { 
        "type": "string" 
       }, 
       "full_size_folder": { 
        "type": "string" 
       }, 
       "group": { 
        "type": "string" 
       }, 
       "hidden_email": { 
        "type": "string" 
       }, 
       "hidden_photographer": { 
        "type": "string" 
       }, 
       "id": { 
        "type": "integer", 
        "ignore_malformed": true, 
        "null_value": -1 
       }, 
       "information": { 
        "type": "string" 
       }, 
       "initial": { 
        "type": "string" 
       }, 
       "ip": { 
        "type": "string" 
       }, 
       "location_id": { 
        "type": "integer", 
        "ignore_malformed": true, 
        "null_value": -1 
       }, 
       "location_verified": { 
        "type": "string" 
       }, 
       "manufacturer": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "military_unit": { 
        "type": "string" 
       }, 
       "model": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "modified_by": { 
        "type": "string" 
       }, 
       "modified_on": { 
        "type": "string" 
       }, 
       "name": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "operator": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "operator_category_id": { 
        "type": "integer", 
        "ignore_malformed": true, 
        "null_value": -1 
       }, 
       "operator_id": { 
        "type": "integer", 
        "ignore_malformed": true, 
        "null_value": -1 
       }, 
       "operator_type": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "operator_verified": { 
        "type": "string" 
       }, 
       "original_filename": { 
        "type": "string" 
       }, 
       "photographer": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "index": "not_analyzed", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "picture_category_id": { 
        "type": "integer", 
        "ignore_malformed": true, 
        "null_value": -1 
       }, 
       "picture_id": { 
        "type": "string" 
       }, 
       "picturecategory_verified": { 
        "type": "string" 
       }, 
       "registration": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "reject_reason": { 
        "type": "string" 
       }, 
       "site_name": { 
        "type": "string" 
       }, 
       "slug": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "subtype": { 
        "type": "string" 
       }, 
       "subtype2": { 
        "type": "string" 
       }, 
       "type": { 
        "type": "string", 
        "fields": { 
        "lower_case_sort": { 
         "type": "string", 
         "analyzer": "case_insensitive_sort" 
        }, 
        "search": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
        } 
       }, 
       "uploaded_file_size": { 
        "type": "string" 
       }, 
       "verified": { 
        "type": "string" 
       }, 
       "views": { 
        "type": "integer", 
        "ignore_malformed": true 
       }, 
       "website": { 
        "type": "string" 
       }, 
       "year": { 
        "type": "integer", 
        "ignore_malformed": true 
       } 
      } 
     } 
     }, 
     "settings": { 
     "index": { 
      "creation_date": "1487318302366", 
      "analysis": { 
       "analyzer": { 
        "case_insensitive_sort": { 
        "filter": [ 
         "lowercase" 
        ], 
        "tokenizer": "keyword" 
        } 
       } 
      }, 
      "number_of_shards": "1", 
      "number_of_replicas": "1", 
      "version": { 
       "created": "1050299" 
      }, 
      "uuid": "KoaR8mksTReY_2mRu4wi-Q" 
     } 
     }, 
     "warmers": {} 
    } 
} 

サンプル文書:

 { 
     "_index": "pictures_testing", 
     "_type": "picture", 
     "_id": "1328215", 
     "_score": 1, 
     "_source": { 
      "id": "1328215", 
      "aircraft_id": "8947", 
      "operator_id": "3273", 
      "operator_category_id": "3", 
      "location_id": "2877", 
      "displayteam_id": null, 
      "airshow_id": null, 
      "picture_category_id": "4", 
      "military_unit": "", 
      "registration": "9M-AQJ", 
      "code_number": "", 
      "construction_number": "28-7125042", 
      "date_taken": "9th March 1975", 
      "date_taken_formatted": "1975-03-09 00:00:00", 
      "year": "1975", 
      "information": "A rather hazy slide being a long shot in 34c.", 
      "approved": null, 
      "display_picture": "yes", 
      "reject_reason": "", 
      "editors_choice": "no", 
      "ab_publication": "", 
      "ab_archive": "no", 
      "correction_id": null, 
      "correction_reason": null, 
      "correction_status": null, 
      "correction_rejection_reason": null, 
      "views": "159", 
      "created_on": "0000-00-00 00:00:00", 
      "created_by": "0", 
      "modified_on": "0000-00-00 00:00:00", 
      "modified_by": null, 
      "date_approved": "2012-01-02 18:58:07", 
      "initial": "P", 
      "manufacturer": "Piper", 
      "type": "Piper PA-28/28R Cherokee", 
      "model": "Piper PA-28-140 Cherokee D", 
      "subtype": "Fixed Wing - Propeller", 
      "subtype2": "Light Aircraft", 
      "verified": "1", 
      "operator": "Private", 
      "operator_type": "Company", 
      "airport": "Kota Kinabalu International (BKI/WBKK)", 
      "country": "Malaysia", 
      "deleted_on": null, 
      "deleted_by": null, 
      "slug": "general", 
      "name": "General", 
      "displayteam": null, 
      "airshow": null, 
      "category": "Light Aircraft", 
      "group": "A", 
      "picture_id": "1328215", 
      "aircraft_verified": "1", 
      "aircraft_type": "Piper PA-28/28R Cherokee", 
      "operator_verified": "1", 
      "location_verified": "1", 
      "displayteam_verified": null, 
      "airshow_verified": null, 
      "picturecategory_verified": "1", 
      "aircraft_type_search": "Piper PA-28/28R Cherokee Piper PA-28-140 Cherokee D" 
     } 
    }, 
    { 
     "_index": "pictures_testing", 
     "_type": "picture", 
     "_id": "1328213", 
     "_score": 1, 
     "_source": { 
      "id": "1328213", 
      "aircraft_id": "5302", 
      "operator_id": "3273", 
      "operator_category_id": "3", 
      "location_id": "2877", 
      "displayteam_id": null, 
      "airshow_id": null, 
      "picture_category_id": "4", 
      "military_unit": "", 
      "registration": "9M-ANZ", 
      "code_number": "", 
      "construction_number": "28-20740", 
      "date_taken": "9th March 1975", 
      "date_taken_formatted": "1975-03-09 00:00:00", 
      "year": "1975", 
      "information": "-", 
      "approved": null, 
      "display_picture": "yes", 
      "reject_reason": "", 
      "editors_choice": "no", 
      "ab_publication": "yes", 
      "ab_archive": "no", 
      "correction_id": null, 
      "correction_reason": null, 
      "correction_status": null, 
      "correction_rejection_reason": null, 
      "views": "126", 
      "created_on": "0000-00-00 00:00:00", 
      "created_by": "0", 
      "modified_on": "0000-00-00 00:00:00", 
      "modified_by": null, 
      "date_approved": "2012-01-02 18:56:27", 
      "initial": "P", 
      "manufacturer": "Piper", 
      "type": "Piper PA-28/28R Cherokee", 
      "model": "Piper PA-28-140 Cherokee", 
      "subtype": "Fixed Wing - Propeller", 
      "subtype2": "Light Aircraft", 
      "verified": "1", 
      "operator": "Private", 
      "operator_type": "Company", 
      "airport": "Kota Kinabalu International (BKI/WBKK)", 
      "country": "Malaysia", 
      "deleted_on": null, 
      "deleted_by": null, 
      "slug": "general", 
      "name": "General", 
      "displayteam": null, 
      "airshow": null, 
      "category": "Light Aircraft", 
      "group": "A", 
      "picture_id": "1328213", 
      "aircraft_verified": "1", 
      "aircraft_type": "Piper PA-28/28R Cherokee", 
      "operator_verified": "1", 
      "location_verified": "1", 
      "displayteam_verified": null, 
      "airshow_verified": null, 
      "picturecategory_verified": "1", 
      "aircraft_type_search": "Piper PA-28/28R Cherokee Piper PA-28-140 Cherokee" 
     } 
    }, 

誰もがここで間違っているかもしれないものを知っていますか?

+0

'curl -XGET localhost:9200/pictures_testing'を実行したときに得られる実際のマッピングを表示できますか?共有したものは公式の構文を使用していないようです。 – Val

+0

aircraft_type_search.searchフィールドは「not_analyzed」なので、クエリに一致するために、aircraft_type_search.searchフィールドには「piper」EXCATLYという単語が含まれていて、その単語(他の単語はない)のみが含まれている必要があります。あなたはそれを認識していますか? (ちょうどチェックして) –

+0

@Valは質問にその出力を加えました。私は構文を説明するかもしれない伸縮性のあるBTWのためのセンスJSONインターフェイスを使用しています。 – jhob101

答えて

0

"aircraft_type_search.search"フィールドのマッピングでは、 "not_analyzed"を使用しないでください。 "not_analyzed"は、フィールドを正確にと同じケースで検索する場合にのみ使用します。

あなたが「パイパー」を検索したときに結果「パイパーPA-28/28RチェロキーパイパーPA-28から140チェロキー」は、その後にマッピングを変更したい場合:

"aircraft_type_search": { 
    "type": "string", 
    "fields": { 
     "lower_case_sort": { 
     "type": "string", 
     "analyzer": "case_insensitive_sort" 
     }, 
     "search": { 
     "type": "string", 
     "analyzer": "standard" // CHANGE HERE 
     } 
    } 
    } 

次に、あなたはありませんワイルドカードクエリを使用します。 の一致クエリを使用してください。

GET /pictures_testing/_search 
{ 
    "query": { 
     "filtered": { 
     "query": { 
      "match": { 
       "aircraft_type_search.search": "piper" 
      } 
     } 
     } 
    } 
} 

これは、「aircraft_type_search」フィールドに「piper」という単語を検索し、検索に一致します。

+0

そのフィールドではうまくいくようですが、ワイルドカードクエリを実行することはできません。これは特に、 "G-BOA、G-BOAB、G-BOAR"などの形式で返された結果を期待する "G-BOA *"の一般的な検索が行われる登録フィールドの問題です。 アナライザーの種類ワイルドカードを使用しないこの種類のクエリに適していますか? ワイルドカードを使用した場合は、特に適したアナライザータイプがありますか? – jhob101

関連する問題