elasticsearch
  • morelikethis
  • 2013-10-23 2 views 0 likes 
    0

    다음 코드는 모든 결과를 "스레드", "_id"로 제한합니다.ElasticSearch more_like_this 제목으로 제한되지 않음

    $data_string = '{ 
    "from" : 0, "size" : 100, 
    "sort" : [ 
        { "date" : {"order" : "desc"} } 
    ], 
    "query": { 
         "match" : { 
          "thread.title" : { 
           "query" : "This is a test" 
          } 
         } 
        } 
    }'; 
    

    내가하고 싶은 것은 일치하는 대신 more_like_this 함수를 사용하는 것입니다. 다음 코드는 작동하지만 "post", "_id"및 "thread", "_id"의 ​​결과를 반환합니다.

    $data_string = '{ 
    "from" : 0, "size" : 100, 
    "sort" : [ 
        { "date" : {"order" : "desc"} } 
    ], 
    "query": { 
         "more_like_this" : { 
          "thread.title" : { 
           "like_text" : "This is a test", 
           "min_word_len" : 2, 
           "min_term_freq" : 1, 
           "min_doc_freq" : 1 
          } 
         } 
        } 
    }'; 
    

    결과를 "스레드", "_id"로 제한하려면 어떻게해야합니까?

    이 내 매핑입니다 :

    { 
        "xenforo120" : { 
        "post" : { 
         "_source" : { 
         "enabled" : false 
         }, 
         "properties" : { 
         "date" : { 
          "type" : "long", 
          "store" : "yes" 
         }, 
         "discussion_id" : { 
          "type" : "long", 
          "store" : "yes" 
         }, 
         "message" : { 
          "type" : "string", 
          "analyzer" : "tweet_analyzer" 
         }, 
         "node" : { 
          "type" : "long" 
         }, 
         "thread" : { 
          "type" : "long" 
         }, 
         "title" : { 
          "type" : "string" 
         }, 
         "user" : { 
          "type" : "long", 
          "store" : "yes" 
         } 
         } 
        }, 
        "profile_post" : { 
         "_source" : { 
         "enabled" : false 
         }, 
         "properties" : { 
         "discussion_id" : { 
          "type" : "long", 
          "store" : "yes" 
         }, 
         "message" : { 
          "type" : "string", 
          "analyzer" : "tweet_analyzer" 
         }, 
         "title" : { 
          "type" : "string" 
         }, 
         "user" : { 
          "type" : "long", 
          "store" : "yes" 
         } 
         } 
        }, 
        "page" : { 
         "properties" : { 
         "date" : { 
          "type" : "long" 
         }, 
         "discussion_id" : { 
          "type" : "long" 
         }, 
         "message" : { 
          "type" : "string" 
         }, 
         "node" : { 
          "type" : "long" 
         }, 
         "title" : { 
          "type" : "string" 
         }, 
         "user" : { 
          "type" : "long" 
         } 
         } 
        }, 
        "thread" : { 
         "_source" : { 
         "enabled" : false 
         }, 
         "properties" : { 
         "date" : { 
          "type" : "long", 
          "store" : "yes" 
         }, 
         "discussion_id" : { 
          "type" : "long", 
          "store" : "yes" 
         }, 
         "message" : { 
          "type" : "string", 
          "analyzer" : "tweet_analyzer" 
         }, 
         "node" : { 
          "type" : "long" 
         }, 
         "thread" : { 
          "type" : "long" 
         }, 
         "title" : { 
          "type" : "string" 
         }, 
         "user" : { 
          "type" : "long", 
          "store" : "yes" 
         } 
         } 
        } 
        } 
    

    답변

    0

    답을 찾을. "more_like_this"대신 "more_like_this_field"를 사용해야했습니다.

     관련 문제

    • 관련 문제 없음^_^