Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.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
Types 将percolator调用限制为ElasticSearch中的类型_Types_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Restrict - Fatal编程技术网 elasticsearch,restrict,Types,elasticsearch,Restrict" /> elasticsearch,restrict,Types,elasticsearch,Restrict" />

Types 将percolator调用限制为ElasticSearch中的类型

Types 将percolator调用限制为ElasticSearch中的类型,types,elasticsearch,restrict,Types,elasticsearch,Restrict,正如文档中所解释的,当我使用_percolator存储查询时,例如: curl -XPUT localhost:9200/_percolator/test/kuku -d '{ "color" : "blue", "query" : { "term" : { "field1" : "value1" } } }' 当我在“test”索引上过滤文档时,将运行此查询,但如果我想将其限制为“test”索引的“foo”类型,唯一的解决方案是在查询中添

正如文档中所解释的,当我使用_percolator存储查询时,例如:

curl -XPUT localhost:9200/_percolator/test/kuku -d '{
  "color" : "blue",
  "query" : {
      "term" : {
        "field1" : "value1"
      }
   }
}'
当我在“test”索引上过滤文档时,将运行此查询,但如果我想将其限制为“test”索引的“foo”类型,唯一的解决方案是在查询中添加一个类型:

curl -XPUT localhost:9200/_percolator/test/kuku -d '{
   "type":"foo",
   "color" : "blue",
   "query" : {
       "term" : {
         "field1" : "value1"
       }
  }
}'
以及在添加文档时使用

curl -XGET localhost:9200/test/type1/_percolate -d '{
   "doc" : {
      "field1" : "value1"
    },
    "query" : {
      "term" : {
         "type" : "foo"
      }
    } 
  }'
还有别的解决办法吗? 我试过了

curl -XPUT localhost:9200/_percolator/test/foo/kuku

但它不起作用。

另一种方法是将原始查询包装到过滤查询中,并为以下类型添加术语过滤器:

{
    "query": {
        "filtered":{
            "query": {
                "term":{
                    field1" : "value1"
                }
             },
             "filter": {
                 "term": {
                     "_type" : "type1"
                 }
              }
          }
     }
}