ravendb combining Search with Where

白昼怎懂夜的黑 提交于 2019-12-23 15:26:41

问题


I am executing a raven query in C#, and utilising both the Where() and Search() extension methods. I need both these functionalities, because I need to only return indices with a specific Guid field, AND text that exists in a body of text. Unfortunatly, the Where extension method seems to not be compatible with the Search extension method. When I combine them I get a Lucene query like this:

    Query:  FeedOwner:25eb541c\-b04a\-4f08\-b468\-65714f259ac2 MessageBody:<<request*>>

Which seems to completely ignore the 'MessageBody' part of the criteria - so it doesnt matter what constraint I use in the 'free text', it doesnt use it.

I have tested with the 'Search' alone, and it works - so its not a problem with free-text searching by itself - just combining the two.


回答1:


Thanks to @Tobias on Raven@GoogleGroups who pointed me in the right direction - there was an option to define how the Where and Search clauses would be combined:

Query<T>.Search(candidate => candidate.MessageBody, queryString + "*", options: SearchOptions.And);


来源:https://stackoverflow.com/questions/11946417/ravendb-combining-search-with-where

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!