2016-10-25 5 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"] 
} 

다음 쿼리가 결과를 반환하지 않는 이유는 무엇입니까? 두 번째 쿼리와 나는 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. 이제 첫 번째 쿼리가 작동합니다. 두 번째 이유는 전혀 결과를주지 않는 이유는 무엇입니까? – betto86

+0

@ betto86이 링크를 확인하십시오. https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html –

관련 문제