Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在大型数据集上返回意外结果的弹性搜索查询_C#_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Nest - Fatal编程技术网 elasticsearch,nest,C#,elasticsearch,Nest" /> elasticsearch,nest,C#,elasticsearch,Nest" />

C# 在大型数据集上返回意外结果的弹性搜索查询

C# 在大型数据集上返回意外结果的弹性搜索查询,c#,elasticsearch,nest,C#,elasticsearch,Nest,我有一个弹性搜索数据库,里面有330万条记录。当我运行这样的搜索时 elasticClient.Search<ElasticIndex>(s => s.Size(100).From(0).Query(q => q.MatchPhrasePrefix(f => f.OnField(i => i.Search).Query("a.b.c.d.e.f")))).Total elasticClient.Search<ElasticInd

我有一个弹性搜索数据库,里面有330万条记录。当我运行这样的搜索时

elasticClient.Search<ElasticIndex>(s => s.Size(100).From(0).Query(q =>
            q.MatchPhrasePrefix(f => f.OnField(i => i.Search).Query("a.b.c.d.e.f")))).Total
elasticClient.Search<ElasticIndex>(s => s.Size(100).From(0).Query(q =>
            q.MatchPhrasePrefix(f => f.OnField(i => i.Search).Query("a.b.c")))).Total
两者都有

{
  "from": 0,
  "size": 100,
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "search": {
              "type": "phrase_prefix",
              "query": "a.b.c.d.e.f"
            }
          }
        },
        {
          "match": {
            "search": {
              "type": "phrase_prefix",
              "query": "a.b.c"
            }
          }
        }
      ]
    }
  }
}

如果在最后一段代码中交换两个查询,即先过滤a.b.c.d.e.f,然后过滤a.b.c.,会发生什么情况?@FrancescoB。同样的东西仍然返回0个结果。请查看一个您希望与Explain API和给定查询匹配的文档(看起来您使用的是Elasticsearch 1.x):。感谢您的建议。最终,对a.b.c.的搜索失败了。短语前缀查找以a.b.c开头的50个术语,然后查找具有其中一个术语的文档。在大型数据集上,a.b.c.d.e.f不是50个术语之一,因此它无法找到文档。有人知道一种替代短语_前缀的方法适用于大型数据集吗?@Cedar您能再解释一下查询的目的吗?目前,
a.b.c
上的
must
子句短语前缀是多余的,因为它包含在
a.b.c.d.e.f
上的
must
子句短语前缀中。如果你能在这个问题上添加一些你想要达到的目标的细节,你也许能提出一些建议。
    {
  "from": 0,
  "size": 100,
  "query": {
    "match": {
      "search": {
        "type": "phrase_prefix",
        "query": "a.b.c.d.e.f"
      }
    }
  }
}
{
  "from": 0,
  "size": 100,
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "search": {
              "type": "phrase_prefix",
              "query": "a.b.c.d.e.f"
            }
          }
        },
        {
          "match": {
            "search": {
              "type": "phrase_prefix",
              "query": "a.b.c"
            }
          }
        }
      ]
    }
  }
}