Search query in RavenDB

I would like to know the search query for the following condition. I created an index called MeetingEventIndex, as shown 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 shown below: Search for a term in a text box or information 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 does not return any result.

I am mainly looking for ((searchterm in the text box || searchterm in the details field) and mrcode in the commroomroom field).

Please, help.

0
source share
1 answer

Your query is probably easier to express as LuceneQuery, rather than:

 docsession.Advanced..LuceneQuery<mngtMeetingEvent, MeetingEventIndex>() .OpenSubClause() .Search("text", search) .OrElse() .Search("details", search) .CloseSubClause() .AndAlso() .WhereEquals("meetingroomid", "123") .ToList(); 
0
source

Source: https://habr.com/ru/post/987280/


All Articles