0

以下代码将所有结果限制为“线程”、“_id”,这很棒。

$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"
        }
      }
    }
  }
4

1 回答 1

0

找到了答案。我需要使用“more_like_this_field”而不是“more_like_this”

于 2013-10-23T16:13:18.910 回答