2017-03-12 8 views
0

find이라는 색인과 song이라는 유형이 있습니다. 송 형 구조 : 때문에 여러 곡의탄성 검색 부스트

"_index": "find", 
    "_type": "song", 
    "_id": "192108", 
    "_source": { 
     "id": 192108,   
     "artist": "Melanie", 
     "title": "Dark Night", 
     "lyrics": "Hot air hangs like a dead man\nFrom a white oak tree", 
     "downloadCount": 234 
    } 

어쩌면 같은 필드 값을 가지고, 그래서 나는 그런 DOWNLOADCOUNT로 인기를 필드에 의해 결과를 높일 필요가있다.

어떻게 아래 쿼리를 downloadCount로 최적화하도록 변경할 수 있습니까?

GET /search/song/_search 
{ 
    "query": { 
     "multi_match": { 
      "query": "like a dead hangs", 
      "type": "most_fields", 
      "fields": ["artist","title","lyrics"], 
      "operator": "or" 
     } 
    } 
} 
+0

어쩌면 사이에 두 개의 인덱스 노래는, 노래는 조금 최고 점수를 가지고 있지만 다른 노래는 사용자들 사이에서 가장 인기가 많은 다운로드가 있습니다. score와 downloadCount 필드 값의 조합으로 결과의 순위를 매길 필요가 있습니다. – Mehmed

답변

0

하여 결과를 높일 수 elastic_search의 field_value_factor 기능을 사용할 수 있습니다. 함수 점수 쿼리는 script_score 함수를 통해 문서 필드를 기반으로 문서 채점을위한 api를 제공합니다.

{ 
    "query": { 
     "function_score": { 
      "query": { 
       "bool": { 
        "must": [{ 
         "term": { 
          "you_filter_field": { 
           "value": "VALUE" 
          } 
         } 
        }] 
       } 
      }, 
      "functions": [{ 
       "script_score": { 
        "script": "doc['downloadCount'].value" 
       } 
      }] 
     } 
    } 
} 

감사