Match exact phrase using elasticsearch Nest

I'm using Nest to build a query. I have a class called Event which has a property called Location and a property called Address (a string). So the indices look something like this:

"id" : "something1",
"location": {
    "address": "The Club",
}

"id" : "something2",
"location": {
    "address": "The Hole",
}

I want to create a query where the user types "The Club" (the location variable) and it only retrieves the first item that has "The Club" as the address

This is my current query

 var skip = (page - 1) * rows;
  var searchResponse = await _elasticClient.SearchAsync<Event>(s => s
            .From(skip)
            .Size(rows)
            .Query(q => q
                .QueryString(qs => qs
                    .Fields(fields => fields
                        .Field(f => f.Location.Address)
                    )
                    .Analyzer("keyword")
                    .Query("*" + (location ?? string.Empty) + "*")
                )
            ));

Currently, the query retrieves both objects since it finds "The". Do I need to add something to my index previously or what should I do?

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