-
-
Save markharwood/2b64e3731d80c8a2b3ac to your computer and use it in GitHub Desktop.
Percolate vs MPercolate on wildcard index names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XGET 'localhost:9200/test*/doc/_mpercolate?pretty' --data-binary "@requests.txt"; echo | |
//requests.txt: | |
{"percolate" : {}} | |
{"doc" : {"name" : "a"}} | |
{"percolate" : {}} | |
{"doc" : {"name" : "b"}} | |
{"percolate" : {}} | |
{"doc" : {"name" : "common"}} | |
//Results as expected: | |
{ | |
"responses" : [ { | |
"took" : 8, | |
"_shards" : { | |
"total" : 10, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"total" : 1, | |
"matches" : [ { | |
"_index" : "testa", | |
"_id" : "testForAorCommon" | |
} ] | |
}, { | |
"took" : 8, | |
"_shards" : { | |
"total" : 10, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"total" : 1, | |
"matches" : [ { | |
"_index" : "testb", | |
"_id" : "testForBorCommon" | |
} ] | |
}, { | |
"took" : 8, | |
"_shards" : { | |
"total" : 10, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"total" : 2, | |
"matches" : [ { | |
"_index" : "testb", | |
"_id" : "testForBorCommon" | |
}, { | |
"_index" : "testa", | |
"_id" : "testForAorCommon" | |
} ] | |
} ] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE testa | |
DELETE testb | |
PUT testa/ | |
{ | |
"mappings": { | |
"doc": { | |
"properties": { | |
"name": { "type": "string" } | |
} | |
} | |
} | |
} | |
PUT testb/ | |
{ | |
"mappings": { | |
"doc": { | |
"properties": { | |
"name": { "type": "string" } | |
} | |
} | |
} | |
} | |
PUT /testa/.percolator/testForAorCommon | |
{ | |
"query" : { | |
"match" : { | |
"name" : "a common" | |
} | |
} | |
} | |
PUT /testb/.percolator/testForBorCommon | |
{ | |
"query" : { | |
"match" : { | |
"name" : "b common" | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET /test*/doc/_percolate | |
{ | |
"doc" : { | |
"name" : "a" | |
} | |
} | |
GET /test*/doc/_percolate | |
{ | |
"doc" : { | |
"name" : "b" | |
} | |
} | |
GET /test*/doc/_percolate | |
{ | |
"doc" : { | |
"name" : "common" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// create 3 identical indices:
PUT /documents_de_1900_1950
PUT /test_a
PUT /test_b
{
"mappings": {
"doc": {
"properties": {
"name": {
"type": "string"
}
}
}
}
}
// percolators in testa, testb; document in documents:
PUT /test_a/.percolator/testForAorCommon
{
"query": {
"match": {
"name": "a common"
}
}
}
PUT /test_b/.percolator/testForBorCommon
{
"query": {
"match": {
"name": "b common"
}
}
}
PUT /documents_de_1900_1950/doc/testdocumenta
{
"name": "a"
}
PUT /documents_de_1900_1950/doc/testdocumentb
{
"name": "b"
}
PUT /documents_de_1900_1950/doc/testdocumentcommon
{
"name": "common"
}
// _percolate works as expected:
GET /documents_de_1900_1950/doc/testdocumentcommon/_percolate?percolate_index=test*
// response:
{
"took": 1,
"_shards": {
"total": 10,
"successful": 10,
"failed": 0
},
"total": 2,
"matches": [
{
"_index": "test_b",
"_id": "testForBorCommon"
},
{
"_index": "test_a",
"_id": "testForAorCommon"
}
]
}
// mpercolate:
{"percolate" : {"index" : "documents_de_1900_1950", "type" : "doc", "id" : "testdocumentcommon", "percolate_index" : "test*" } }
{}
// windows Result:
D:\curl-7.45.0-win64-mingw\bin>curl -XPOST "http://localhost:9200/_mpercolate?pretty" --data-binary "@mpercolator.txt"
{
"responses" : [ {
"took" : 1,
"_shards" : {
"total" : 10,
"successful" : 5,
"failed" : 0
},
"total" : 2,
"matches" : [ {
"_index" : "test_b",
"_id" : "testForBorCommon"
}, {
"_index" : "test_a",
"_id" : "testForAorCommon"
} ]
} ]
}
// linux Result:
[tomcat@office ~]$ curl -XPOST "http://192.168.2.60:9200/_mpercolate?pretty" --data-binary @perc.txt
{
"responses" : [ {
"took" : 19,
"_shards" : {
"total" : 10,
"successful" : 5,
"failed" : 0
},
"total" : 1,
"matches" : [ {
"_index" : "test_b",
"_id" : "testForBorCommon"
} ]
} ]
}