Elasticsearch 8.5 Multi-Index Search with Different Mappings scenarios to Return Consistent Results
I'm dealing with I've searched everywhere and can't find a clear answer... I've been struggling with this for a few days now and could really use some help. I'm currently working with Elasticsearch 8.5 and am working with a peculiar scenario with multi-index searches. I have two indices, `index_a` and `index_b`, each with different mappings. `index_a` has a `created_at` field of type `date`, while `index_b` has it as a `text` field due to legacy reasons. When I perform a search across both indices with a query that filters by date, I'm not getting consistent results. Hereโs the query Iโm using: ```json { "query": { "bool": { "must": [ { "range": { "created_at": { "gte": "2023-01-01", "lt": "2023-12-31" } } } ] } } } ``` When I execute this query, I see the following behavior for `index_b`: ``` Invalid date format for field [created_at] in index [index_b]. Expected [date] but got [text]. ``` I tried to work around this by explicitly specifying the index in the query, but the results are still not as expected. For example, if I query `index_a` alone, I get 150 documents, while querying `index_b` gives me zero results even though I know there should be a few records that match the date range. Iโve also tried using `match` instead of `range` for `index_b`, but I still canโt retrieve any data related to dates. Is there a way to handle this scenario effectively? Should I consider reindexing `index_b` to a more appropriate mapping, or is there a better approach to query across these indices without losing data integrity? I'm working on a web app that needs to handle this. This is part of a larger mobile app I'm building. Is there a simpler solution I'm overlooking? This is happening in both development and production on CentOS.