Reputation: 1944
In elasticsearch, is it possible to define wildcard types (index)?
For example: I have an index named miner and have types P1, P2, N1, N2.
I want to search index: miner with all types starting with 'P'. I tried 'P*' and does not work. Is it possible?
client.search({
index: 'miner',
type: 'P*',
Thank you
Upvotes: 1
Views: 648
Reputation: 52368
You need a prefix query for field _type
. My example below demonstrates the prefix
query together with whatever else you would like to search your index:
GET /miner/_search
{
"query": {
"bool": {
"must": [
{
"prefix": {
"_type": {
"value": "test"
}
}
},
{
"match": {
"name": "bob"
}
}
]
}
}
}
Upvotes: 1