2016-10-25 22 views
3

私はどのようにしているのですか?このクエリのようなものが動作します(ES 2.X)。 以下のインデックスをタームベクトルで作成しました。Elasticsearch More同様の結果はありません。

PUT /test_index 
{ 
    "settings": { 
     "number_of_shards": 1, 
     "number_of_replicas": 0 
    }, 
    "mappings": { 
     "doc": { 
     "properties": { 
      "text": { 
       "type": "string", 
       "term_vector": "yes" 
      } 
     } 
     } 
    } 
} 

PUT /test_index/doc/1 
{ 
    "text": ["Hello","World"] 
} 

PUT /test_index/doc/2 
{ 
    "text": ["This","is","me"] 
} 

PUT /test_index/doc/3 
{ 
    "text": ["Hello","World"] 
} 

PUT /test_index/doc/4 
{ 
    "text": ["Hello","World","World"] 
} 

なぜ次のクエリは結果を返さないのですか? 2番目のクエリで、私は1

POST /test_index/doc/_search 
{ 
    "query": { 
     "more_like_this": { 
     "like": "Hello", 
     "min_term_freq": 1 
     } 
    } 
} 

POST /test_index/doc/_search 
{ 
    "query": { 
     "more_like_this": { 
     "fields": [ 
      "text" 
     ], 
     "like": [ 
      { 
       "_index": "test_index", 
       "_type": "doc", 
       "_id": "1" 
      } 
     ] 
     } 
    } 
} 

答えて

7

デフォルトmin_doc_freqが5である、だからあなたのインデックスが少なくとも含まれていないため、クエリが動作していないことでドキュメントの同じ値を有する少なくともドキュメント3を取得することが期待しましたtermプロパティが黄色の5つの文書。したがって、クエリでmin_doc_freqを1に設定するとうまくいくはずです。

{ 
    "query": { 
     "more_like_this": { 
      "like": "Hello", 
      "min_term_freq": 1, 
      "min_doc_freq": 1 
     } 
    } 
} 
+0

ありがとうございましたvinod_vh。今すぐ最初のクエリが動作します。なぜ2番目のものは私に全く結果を与えませんか? – betto86

+0

@ betto86このリンクを確認してくださいhttps://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html –

関連する問題