ElasticSearch-NEST Query String Phrase


(Emre K) #1

I have a problem with ElasticSearch query phrases. My index document is;

    var person = new Person
    {
        Id = "4",
        Firstname = "ali ahmet",
        Lastname = "yazıcı"
    };

var index = client.Index(person, x => x.Index("personindex"));

My search phrase is;

    var result = client.Search<Person>(s => s
        .From(0)
        .Size(10)
        .Query(q => q
            .SimpleQueryString(qs => qs
                .OnFields(new[]{"firstname","lastname"})
                .Query("\"ali ah*\"")
            )
        )
  );
indent preformatted text by 4 spaces

Result document is empty. But when i change my phrase to

.Query("\"ali ahmet\"")

result is coming. Why return empty result from

.Query("\"ali ah*\"")

this phrase. Word order is very important for me. First word must be "ali" and second word must be "ah*".

ALSO

Person Class

public class Person
{
    public string Id { get; set; }
    public string Firstname { get; set; }
    public string Lastname { get; set; }
}

Index mapping

var response = client.CreateIndex("personindex", c => c
            .AddMapping<Person>(m => m.MapFromAttributes())

(Eugeniy) #2

try to use queryContainer and QueryString, this can help :wink:


(system) #3