【问题标题】:Elastic Search returns inconsistent results on running the same query multiple timesElastic Search 在多次运行相同查询时返回不一致的结果
【发布时间】:2014-10-29 10:40:40
【问题描述】:

我们在单个节点上使用弹性搜索对数据进行了索引。我们在后台运行了一个线程,用于使用最近的更改更新索引。

现在我们使用弹性搜索 API 来运行搜索查询。

{
  "from" : 0,
  "size" : 20,
  "timeout" : 0,
  "query" : {
    "filtered" : {
      "query" : {
        "query_string" : {
          "query" : "Bug-157099*",
          "default_field" : "_content",
          "default_operator" : "and",
          "allow_leading_wildcard" : true,
          "analyze_wildcard" : true
        }
      },
      "filter" : {
        "fquery" : {
          "query" : {
            "query_string" : {
              "query" : "pxObjClass:(\"ProjMgmt-Work-Project\")",
              "default_field" : "_content",
              "default_operator" : "and",
              "allow_leading_wildcard" : true
            }
          },
          "_cache" : false
        }
      }
    }
  },
  "fields" : "*"
}

但是,搜索查询返回的结果不一致。在连续重新运行查询时,有时我们得到 0 个结果,有时是部分结果,有时我们得到完整的结果。

我们在只有一个节点是索引节点的集群中面临这个问题。

您能否告诉我们可能导致此问题的原因?

【问题讨论】:

  • 您能否提供更多信息:例如你用什么查询?
  • 这是一个过滤查询。

标签: search elasticsearch


【解决方案1】:

问题是由于查询中设置的超时造成的。在我们代码的某些部分,我们将超时设置为零。我们更正了代码,现在查询工作正常。

我在这里插入了正确的查询

{
  "from" : 0,
  "size" : 20,
  "query" : {
    "filtered" : {
      "query" : {
        "query_string" : {
          "query" : "BUg-157099*",
          "default_field" : "_content",
          "default_operator" : "and",
          "allow_leading_wildcard" : true,
          "analyze_wildcard" : true
        }
      },
      "filter" : {
        "fquery" : {
          "query" : {
            "query_string" : {
              "query" : "pxObjClass:(\"ProjMgmt-Work-Project\")",
              "default_field" : "_content",
              "default_operator" : "and",
              "allow_leading_wildcard" : true
            }
          },
          "_cache" : false
        }
      }
    }
  },
  "fields" : "*"
}

【讨论】:

    猜你喜欢
    • 2016-09-29
    • 2013-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多