Wildcard Search

Vote:
 

I am working on a project where we have moved from the standard episerver seach mechanisim to episerver find.

We needed to be able to use wildcard searching, but due to the nature of the pagetypes we where searching across we could not use the .Filter(f => f.PageName.Prefix(this.SearchTerm)), the properties we needed to search against where not consistent across all the pagetypes.


We where forced to the the .For(this.SearchTerm) method, but it isn't possible to force a wildcard search.


After looking at the documentation I knew that the .For() method works against a specific field '_all', so all I needed to do was use the Filter() method, and then specify this field.

.Filter(new PrefixFilter("_all", this.SearchTerm))

The line above allows makes the query perfom a wildcard search on the '_all' field, just what I needed to do.


Hopefully this will help, but interested to get peoples thoughts on other possible solutions.

 

#83199
Mar 27, 2014 13:16
Vote:
 

Hi,

Joel Abrahamsson has written a post of how to do wildcard queries: http://joelabrahamsson.com/wildcard-queries-with-episerver-find/

Best Regards,

Henrik

#83202
Mar 27, 2014 13:22
Vote:
 

Hi,

The solution outlined in the post doesn't solve my exact problem.  You still need to specify the fields you want to search against, but my problem is that the pages types that I have to search against do not share a common set of properties.  This is why I use the '_all' field.

Having said that, it isn't much of a change to alter the 'WildCardQuery' extension method to fit my requirements.  I just remove fieldselector expression parameter and default to the '_all' field.

 

Thanks

#83204
Mar 27, 2014 13:49
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.