search query in elasticsearch
<p>I have documents like the below in my elasticsearch</p>

<pre><code>{"method":"POST","url":"/saas/services/1.0/account/*/purchase/*/subscription/cancel"}
{"method":"POST","url":"/saas/services/1.0/account/*/purchase/*/cancel"}
</code></pre>

<p>I am searching these documents using node.js client. Below is the query I am sending. </p>

<p>Example 1 type : DSL</p>

<pre><code>client.search({
    index: 'my_node',
    body: {
        query: {
            bool: {
                must: {
                    match: { method: 'POST' },
                    match: { url: '/saas/services/1.0/account/*/purchase/*/cancel' }
                }
            }
        }
    }
}
</code></pre>

<p>Output
I am getting the other record with subscription cancel. The query is not matching the exact document. I tried the below query , it worked for this case but not working for few other test cases.</p>

<p>document</p>

<pre><code>  {"method":"POST","url":"/paas/service/1.0/act/*/purchase"}}
    {"method":"GET","url":"/paas/service/1.0/act/*/purchase"}}
    {"method":"PUT","url":"/paas/service/1.0/act/*/purchase"}}
</code></pre>

<p>Example 2 type : query string</p>

<pre><code>    client.search({
  index: 'my_node',
  q: 'method: POST AND url: /saas/services/1.0/account/*/purchase'
}
</code></pre>

<p>Output</p>

<p>I get the GET purchase document regardless of other two. Tried for few other documents, the method argument is not getting recognized.</p>

<p>How do I write elasticsearch query to search through the documents to match both the properties of method and url. i had tried query time boosting for the url but doesn't seem to work. </p>

<p>Edit - Mapping information</p>

<pre><code> {
  "nodeclient": {
    "mappings": {
      "logs": {
        "properties": {
          "method": {
            "type": "string" },
          "url": {
            "type": "string" }
     } } }
  }
}
</code></pre>