2016-05-17 148 views
0

我想獲得存儲在ES中的布爾查詢,使用Percolate API。下面彈性搜索滲透布爾查詢

curl -XPUT 'localhost:9200/my-index' -d '{ 
    "mappings": { 
    "taggers": { 
     "properties": { 
     "content": { 
      "type": "string" 
     } 
     } 
    } 
    } 
}' 

指數映射給我插入這樣的記錄(查詢包含適當的布爾格式(AND,OR,NOT等),如下面的例子給出)

curl -XPUT 'localhost:9200/my-index/.percolator/1' -d '{ 
     "query" : { 
      "match" : { 
       "content" : "Audi AND BMW" 
      } 
     } 
}' 

而且然後我發佈文檔以獲得匹配的查詢。

curl -XGET 'localhost:9200/my-index/my-type/_percolate' -d '{ 
    "doc" : { 
     "content" : "I like audi very much" 
    } 
}' 

在上述情況下,沒有記錄應該來,因爲布爾查詢是「奧迪寶馬」,但它仍然給記錄。這意味着它忽略了的條件。我無法弄清楚爲什麼它不適用於布爾查詢。

回答

0

您需要滲透此查詢,而不是match查詢不瞭解AND運算符(它們會將它視爲正常標記and),但query_string

curl -XPUT 'localhost:9200/my-index/.percolator/1' -d '{ 
    "query" : { 
     "query_string" : { 
      "query" : "Audi AND BMW", 
      "default_field": "content" 
     } 
    } 
}'