Searching by exact match word or email address should display at top

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Sid
Reply | Threaded
Open this post in threaded view
|

Searching by exact match word or email address should display at top

Sid
This post has NOT been accepted by the mailing list yet.
Hi,

In global serach, i am searching for email id of any user say user@gmail.com.

The result i am getting:All the users are displaying
Expected Result: only user whose email is matching should be displayed.
 
I am using the below es query.

{
        "query":
{
  "filtered" : {
    "query" : {
      "bool" : {
        "must" : {
          "flt" : {
            "like_text" : "user@gmail.com"
          }
        },
        "should" : {
          "bool" : {
            "should" : [ {
              "bool" : {
                "should" : {
                  "match" : {
                    "country.code" : {
                      "query" : "SG",
                      "type" : "boolean"
                    }
                  }
                }
              }
            }, {
              "match" : {
                "market.code" : {
                  "query" : "RESELLER",
                  "type" : "boolean"
                }
              }
            } ]
          }
        },
        "minimum_should_match" : "2"
      }
    },
    "filter" : {
      "bool" : {
        "should" : [ {
          "type" : {
            "value" : "user"
          }
        }, {
          "type" : {
            "value" : "keyword"
          }
        }, {
          "type" : {
            "value" : "tag"
          }
        }, {
          "type" : {
            "value" : "event"
          }
        }, {
          "type" : {
            "value" : "attendee"
          }
        }, {
          "type" : {
            "value" : "ethics"
          }
        } ]
      }
    }
  }
}}

I am facing the below problems
1) If i am searching for any word then i found the record in the result but not at the top. My requirement is The exact match word should be displayed at top means first record.

2)if i am searching for email address. I'm getting all the results. My req is exact match user@gmail.com should be displayed.

Please help me for fixing the problems.