kay-is
(K.)
June 25, 2019, 12:13pm
1
I have some tagged images in my Elasticsearch and want to query them with a wildcard and an exact match.
POST images/image
{
"fileName": "1319410514097402934+test",
"tags": ["someTag", "someOtherTag"]
}
POST images/_search
{
"query": {
"bool": {
"must": { "wildcard": { "fileName": "*test" },
"filter": { "match": { "tags": ["someTag"] } }
}
}
}
But I'm getting the following error:
{
"type": "illegal_state_exception",
"reason": "Can't get text on a START_ARRAY at 1:79"
}
How do I fix this?
dadoonet
(David Pilato)
June 25, 2019, 1:18pm
2
Try this:
POST images/_search
{
"query": {
"bool": {
"must": [{ "wildcard": { "fileName": "*test" }],
"filter": [{ "match": { "tags": ["someTag"] } }]
}
}
}
BTW this is scary to run: { "wildcard": { "fileName": "*test" }
. Unless you like slow queries, don't do that.
1 Like
kay-is
(K.)
June 25, 2019, 1:32pm
3
Thanks, I will try this
BTW this is scary to run: { "wildcard": { "fileName": "*test" }
. Unless you like slow queries, don't do that.
What should I do instead?
kay-is
(K.)
June 26, 2019, 2:35pm
4
Your query didn't work.
I'm still getting the array error:
{
"type": "illegal_state_exception",
"reason": "Can't get text on a START_ARRAY at 1:82"
}
Sent this:
{
"query": {
"bool": {
"must": [
{
"wildcard": {
"fileName": "*test"
}
}
],
"filter": [
{
"match": {
"tags": [
"no"
]
}
}
]
}
}
}
dadoonet
(David Pilato)
June 26, 2019, 3:18pm
5
The match query is incorrect.
GET _search
{
"query": {
"bool": {
"must": [
{
"wildcard": {
"fileName": "*test"
}
}
],
"filter": [
{
"match": {
"tags": "no"
}
}
]
}
}
}
kay-is
(K.)
June 26, 2019, 3:31pm
6
I see, so I "have to" use "tags": "no"
for one value in the array and "tags": ["no", "people"]
for multiple ones?
dadoonet
(David Pilato)
June 26, 2019, 3:47pm
7
Multiple match queries I'd say.
system
(system)
Closed
July 24, 2019, 3:47pm
8
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.