Hey guys, I have 2 different indexes that store information about my users.
Both use a hashed version of their id_number as their doc_id, I`m trying to create a query that will look for different fields in both indexes and return me the users that match. My current problem is that even tho I have users that match my query, my query keeps returning 0 results.
Index1 data
{
"_index" : "index1",
"_type" : "_doc",
"_id" : "7820b6dfed99773990650168c55b1135",
"_score" : 12.400421,
"_source" : {
"user_id" : 25,
"date" : "2023-08-01T10:10:37",
"name": "John",
"age" : 20,
"country" : "US",
"sessions" : 8
}
}
Index2 Data
{
"_index" : "index2",
"_type" : "_doc",
"_id" : "7820b6dfed99773990650168c55b1135",
"_score" : 12.400421,
"_source" : {
"user_id" : 25,
"company_id": 1,
"status": "active"
}
}
Query
GET /index1,index2/_search
{
"query": {
"bool": {
"must" : [
{
"match": {"status": "active"}
},
{
"bool": {
"should" : [
{
"match": {"age": 20}
},
{
"range": {
"sessions": {"gte": 5}
}
}
]
}
}
],
"must_not" : [
{
"match": {
"company_id": 2
}
}
]
}
}
}
For some reason, the query works just fine if I only include fields from the same index in the must argument, but as soon as I add a field from a different index in the must statement it returns 0 results