How to make Elasticsearch can search from another field when have some specific keyword

Hello, This is my example data about event or meeting organization.

I want to perform searching like "Songkarn holiday in Bangkok" and Elasticsearch will know automatically that "in [Bangkok]" is it mean my location fields then will try to use BoolQuery between eventDetail and location.

In the programming perhaps I can use if-else or some sort like that to filter manaully but in the Elasticsearch does it have any way to do something like this ? maybe writing some script to Elasticsearch ? I have read about machine learning in elasticsearch but I think maybe it too over-engineering ? (ofcourse if it must be the way like that I also want to try it :slight_smile:

Thank you in advance !!!


How about always searching in all your fields and put weight to prioritize.

Check about query string with muti-fields

    "query": {
        "query_string" : {
            "fields" : ["eventDetail^2", "location^5"],
            "query" : "Songkarn holiday in Bangkok"

If it hit it will return the one with Bankok in location and title, then the one with only bankok in location then the one with bankok in eventDetail.

you also need to add a bool should around and some term or match to hit more results.


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