问题
I would like to know the Search Query for the below condition. I have created an index called MeetingEventIndex as below:
public class MeetingEventIndex : AbstractIndexCreationTask<mngtMeetingEvent>
{
public MeetingEventIndex ()
{
Map = docs => from d in docs select new {d.meetingroomid, d.text, d.details};
Index(x=>x.meetingroomid, FieldIndexing.Analyzed);
Index(x=>x.text, FieldIndexing.Analyzed);
Index(x=>x.details, FieldIndexing.Analyzed);
}
}
I am trying to create a search query as below "Search the term in text or details field and meetingroomid==123"
docsession.Query<mngtMeetingEvent, MeetingEventIndex>()
.Search(x=>x.text , search)
.Search(x=>x.details, search. options: SearchOptions.Or)
.Search(x=>x.meetingroomid, "123", option.SearchOptions.And)
.ToList()
But this is not returning any result.
Basically I am looking for ((searchterm in text field || searchterm in details field ) and mrcode in meetingroomid field).
Please help.
回答1:
Your query is probably more easily expressed as LuceneQuery, instead:
docsession.Advanced..LuceneQuery<mngtMeetingEvent, MeetingEventIndex>()
.OpenSubClause()
.Search("text", search)
.OrElse()
.Search("details", search)
.CloseSubClause()
.AndAlso()
.WhereEquals("meetingroomid", "123")
.ToList();
来源:https://stackoverflow.com/questions/24625040/search-query-in-ravendb