4

I have a common term query like so.

{
    "query" : {
        "common" : {
            "DocumentData.OCR_Text" : {
                "query" : "block 310 luis",
                "cutoff_frequency" : 0.001
            }
        }
    }
}

I want to search on 2 or more fields but this gives me an error.

{
    "query" : {
        "common" : {
            "Grantors" : {
                    "query" : "block 310 luis",
                    "cutoff_frequency" : 0.001
                },
            "DocumentData.OCR_Text" : {
                "query" : "block 310 luis",
                "cutoff_frequency" : 0.001
            }
        }
    }
}

nested: ElasticsearchParseException[Expected field name but got START_OBJECT "DocumentData.OCR_Text"];

How would you do this?

1 Answer 1

8

You should wrap it in a Bool Query

{
    "query": {
        "bool": {
            "should": [
                {
                    "common": {
                        "Grantors": {
                            "query": "block 310 luis",
                            "cutoff_frequency": 0.001
                        }
                    }
                },
                {
                    "common": {
                        "DocumentData.OCR_Text": {
                            "query": "block 310 luis",
                            "cutoff_frequency": 0.001
                        }
                    }
                }
            ]
        }
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.