Smart Search query

I want to write a query to be able to search across all fields in my Elasticsearch index. I used the bulk API to insert data to es and didn't choose any particular analyzer while indexing. By default my fields will be analyzed and I don't want to change my mapping.

I want to create a query that searches a piece of text inside all fields in elasticsearch and returns all documents which contain that text as a substring in some field. One way is to use the MatchPhrasePrefix query for each field along with the OR boolquery across all fields to search all over the document. Some of my fields are strings and some are maps of strings. MatchPhrasePrefix query for string is fine. But for the maps of strings, the keys are not fixed and the user can enter any key and any number of keys. So I am stuck on how to use the MatchPhrasePrefix query across all keys of such a map, where keys themselves are not fixed. If the keys were fixed , I would have looped across the map entries and used the query MatchPhrasePefixQuery("mapname.key","string") along with OR query.

I want to write a query to be able to search across all fields in my Elasticsearch index. I used the bulk API to insert data to es and didn't choose any particular analyzer while indexing. By default my fields will be analyzed and I don't want to change my indexing.

I want to create a query that searches a piece of text inside all fields in elasticsearch and returns all documents which contain that text as a substring in some field. One way is to use the MatchPhrasePrefix query for each field along with the OR boolquery across all fields to search all over the document. Some of my fields are strings and some are maps of strings. MatchPhrasePrefix query for string is fine. But for the maps of strings, the keys are not fixed and the user can enter any key and any number of keys. So I am stuck on how to use the MatchPhrasePrefix query across all keys of such a map, where keys themselves are not fixed. If the keys were fixed , I would have looped across the map entries and used the query MatchPhrasePefixQuery("mapname.key","string") along with OR query.

I agree I can use QueryString and SimpleQueryString and use wildcard on keys like Query("mapname.*","string"), but it's not giving me correct results. So I am using MatchPhrasePrefix query as my fields are analyzed.

Any suggestions on how I can search a string in such a dynamic map field. If not this, then how can I search a string across my document in elasticsearch 7.4 where there is no _all field?

Any suggestions on how I can search a string in such a dynamic map field. If not this, then how can I search a string across my document in elasticsearch 7.4 where there is no _all field?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.