簡體   English   中英

Elasticsearch查詢未返回任何內容

[英]Elasticsearch query not returning anything

我已將以下文檔編入索引,但運行搜索時未返回任何內容,我想知道它是否與查詢有關。 我正在嘗試搜索其中包含單詞dogs的任何嵌套消息。 這是文檔:

{
"_index": "thread_and_messages",
"_type": "thread",
"_id": "3",
"_score": 1.0,
"_source": {
    "thread_id": 3,
    "thread_name": "I play the guitar",
    "created": "Wed Apr 13 2016",
    "thread_view": 2,
    "first_nick": "Test User",
    "messages": [{
        "message_text": " I like dogs",
        "message_id": 13,
        "message_nick": "Test"
    }],
    "site_name": "Test Site"
}
}

這是我運行curl命令時正在運行的查詢:

{
"function_score": {
    "functions": [{
        "field_value_factor": {
            "field": "thread_view",
            "modifier": "log1p",
            "factor": 2
        }
    }],
    {"query": {
        "bool": {
            "should": [{
                "match": {
                    "thread_name": "dogs"
                }
            }, {
                "nested": {
                    "path": "messages",
                    "query": {
                        "bool": {
                            "should": [{
                                "match": {
                                    "messages.message_text": "dogs"
                                }
                            }]
                        }
                    },
                    "inner_hits": {}
                }
            }]
        }
    }
}
}

您所擁有的映射以及帶有稍微修改的查詢的示例文檔對我有用:

curl -XGET "http://localhost:9200/thread_and_messages/thread/_search" -d'
{
  "query": {
    "function_score": {
      "functions": [
        {
          "field_value_factor": {
            "field": "thread_view",
            "modifier": "log1p",
            "factor": 2
          }
        }
      ],
      "query": {
        "bool": {
          "should": [
            {
              "match": {
                "thread_name": "dogs"
              }
            },
            {
              "nested": {
                "path": "messages",
                "query": {
                  "bool": {
                    "should": [
                      {
                        "match": {
                          "messages.message_text": "dogs"
                        }
                      }
                    ]
                  }
                },
                "inner_hits": {}
              }
            }
          ]
        }
      }
    }
  }
}'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM