I am trying to use Nest C# and link to an textbox for searching. I have multiple fields that I would like to search on but I cant get it working right.
This works for me if I am searching one field [Title] for the partial text of "tit" to match something with the value of "title" , but I have 2 more fields I want to add to the search as well.
var searchResponse = client.Search<Search>(s => s
.Query(q => q.MatchPhrasePrefix(m => m.Field(f=>f.Title).Query("tit").MaxExpansions(10)))
.Index("myindex")
);
You can use a multi match phrase prefix query
client.Search<Search>(s => s
.Query(q => q
.MultiMatch(mm => mm
.Fields(f => f
.Field(ff => ff.Title)
.Field(ff => ff.Message)
.Field(ff => ff.Description)
)
.Type(TextQueryType.PhrasePrefix)
.Query("tit")
.MaxExpansions(10)
)
)
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.