# Query DSL: how to use phrase\_prefix in query string?

**URL:** <https://discuss.elastic.co/t/query-dsl-how-to-use-phrase-prefix-in-query-string/102410>\
**Category:** Elasticsearch\
**Created:** [October 2, 2017, 7:57am UTC](https://discuss.elastic.co/t/query-dsl-how-to-use-phrase-prefix-in-query-string/102410 "2017-10-02T07:57:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maralbe](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@maralbe](https://discuss.elastic.co/u/maralbe)\
**Post date:** [October 2, 2017, 7:57am UTC](https://discuss.elastic.co/t/query-dsl-how-to-use-phrase-prefix-in-query-string/102410/1 "2017-10-02T07:57:41Z")

</div>

Hi, I want to search thorough hole my documents, and for a specific query I want it returns results with suffix and prefix.. right now when my query run.. it returns just documents that have exact value, that have been searched, for my search structure I have three way:

1. I want documents that have the exact value (right now it works as I expected)
2. I want documents that have part of that query.. (for example: if I search engineer... the search result returns engineering too. (right now it doesn't)).
3. my query may have one or more word.. so I want my search results returns documents that have one or more query in them..

this is part of my query:

```
[
   "query" => [
      "bool" => [
        "must" => [
          [
           "query_string" => [
               "query" => "engineer"
               "boost" => 1
             ]
           ]
           [
            "query_string" => [
                "query" => ""engineer*""
                "default_operator" => "AND"
              ]
            ]
            [
               "query_string" => [
                  "query" => "engineer"
                  "default_operator" => "OR"
               ]
            ]
        ]
        "must_not" => []
        "filter" => []
     ]
   ]
]

```

after I searched more.. I found this:

```
[
    "query" => [
      "bool" => [
        "must" => [
          [
            "query_string" => [
              "query" => "engineering chemic*"
              "analyze_wildcard" => true
              "default_operator" => "OR"
            ]
          ]
          [
            "multi_match" => [
              "query" => "engineering chemic"
              "type" => "phrase_prefix"
              "fields" => [
                "educations.education_title"
              ]
            ]
          ]
        ]
        "must_not" => []
        "filter" => []
      ]
    ]
  ]

```

here if I want `one_or_more search`: it just return documents that have both strings.. just return 1 result..  
and if my query was :`"engineering"` it returns 4 results... the point is I want it returns me 5 results if I search for `"engineering chemic"` but returns 1.. the document that have both of them!

and also I don't know how `"phrase_prefix"` on hole my document.. currently I used that for certain fields.. but I want that for hole document.

can anyone help me to how get my result with different conditions that I explained above?  
thanks

---

<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:** [October 30, 2017, 7:58am UTC](https://discuss.elastic.co/t/query-dsl-how-to-use-phrase-prefix-in-query-string/102410/2 "2017-10-30T07:58:04Z")

</div>

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