# Incoporating search with Boolean Queries?

**URL:** <https://discuss.elastic.co/t/incoporating-search-with-boolean-queries/220649>\
**Category:** Elasticsearch\
**Created:** [February 24, 2020, 12:52pm UTC](https://discuss.elastic.co/t/incoporating-search-with-boolean-queries/220649 "2020-02-24T12:52:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhijith\_chandran](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhijith_chandran/32/60470_2.png) [@abhijith\_chandran](https://discuss.elastic.co/u/abhijith_chandran)\
**Post date:** [February 24, 2020, 12:52pm UTC](https://discuss.elastic.co/t/incoporating-search-with-boolean-queries/220649/1 "2020-02-24T12:52:12Z")

</div>

Hi,  
I am currently using the following query -

```auto
{
    "_source": [
        "title",
        "bench",
        "id_",
        "court",
        "date",
        "content"
    ],
    "size": 15,
    "from": 0,
    "query": {
        "bool": {
            "must": [
                {
                    "multi_match": {
                        "query": "the",
                        "fields": [
                            
                            "content"
                        ], "operator": "and"
                    }
                },
               
            ],
            "should": {
                "multi_match": {
                    "query": "the",
                    "fields": [
                        "content.standard^2"
                    ], "operator": "and"
                }
            }
        }
    }
    ,
    "highlight": {
        "pre_tags": [
            "<tag1>"
        ],
        "post_tags": [
            "</tag1>"
        ],
        "fields": {
            "content": {}
        },
        "fragment_size": 100
    }
}

```

With the following mapping

```auto
{
    "courts_2": {
        "mappings": {
            "properties": {
                "author": {
                    "type": "text",
                    "analyzer": "my_analyzer"
                },
                "bench": {
                    "type": "text",
                    "analyzer": "my_analyzer"
                },
                "citation": {
                    "type": "text"
                },
                "content": {
                    "type": "text",
                    "fields": {
                        "standard": {
                            "type": "text"
                        }
                    },
                    "analyzer": "my_analyzer"
                },
                "court": {
                    "type": "text"
                },
                "date": {
                    "type": "text"
                },
                "id_": {
                    "type": "text"
                },
                "title": {
                    "type": "text",
                    "fields": {
                        "standard": {
                            "type": "text"
                        }
                    },
                    "analyzer": "my_analyzer"
                },
                "verdict": {
                    "type": "text"
                }
            }
        }
    }
}

```

`My analyzer` is a metaphone analyzer.  
Here is my Aim. I want the exact matches ( `standard` ) to appear first, followed by phonetic ones. I am able to achieve that with the code. I am pretty sure that there is (are) some unwanted logic in this and would deeply appriciate if someone can point to it.

Additionally what I would like to incorporate is a search logic where a user can enter a search like

```auto
Real Madrid AND Barcelona OR Manchester United. 

```

Here I want all documents that contain Real Madrid and either Barcelona/Man Utd/ How do I achieve with the current query I have in place (with modifications)?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 23, 2020, 12:52pm UTC](https://discuss.elastic.co/t/incoporating-search-with-boolean-queries/220649/2 "2020-03-23T12:52:16Z")

</div>

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