弾性検索では、このフィルター
{
"bool": {
"must": {
"term": {
"article.title": "google"
}
}
}
}
タイトルに「google」が含まれる記事を適切に返します。
でも、
{
"bool": {
"must": {
"term": {
"article.title": "google earth"
}
}
}
}
タイトルに「google Earth」という正確な単語が含まれる記事があるにもかかわらず、結果が返されません。そうしてほしいです。
完全なクエリ:
{
"size": 200,
"filter": {
"bool": {
"must": {
"term": {
"article.title": "google maps"
}
}
}
},
{
"range": {
"created_date": {
"from": "2013-01-11T02:14:03.352Z"
}
}
}]
}
}
ご覧のとおり、「クエリ」はありません。フィルター、サイズ、範囲だけです。それで、ElasticSearchがデフォルトのアナライザーを使用していると思います...?
私は何を誤解していますか?
編集:解決策を探している人のために、ここに私のフィルターがあります:
{
"query": {
"bool": {
"must": {
"must_match": {
"article.title": "google earth"
}
}
}
}
}
(1) "query" で bool フィルターをラップし、(2) "term" を "must_match" に変更したノード。これにより、(記事を検索する "match" とは対照的に) フレーズ全体が一致します。グーグルアースの標準アナライザーでタイトル)。
完全なクエリは次のようになります。
{
"size": 200,
"filter": {
"query": {
"bool": {
"must": {
"must_match": {
"article.title": "google earth"
}
}
}
}
}
}
FWIW、(標準クエリを使用するのではなく) 「フィルター」フィールド内にこの条件を設定する理由は、「must_not」の代わりに「must_not」を使用したい場合があり、他の要素をクエリ。