c# - Searching for fields that contains the search term -
i did studies on lucene search queries , searched internet answers on how this... couldn't find method works , attempts failed, not returning want.
basically, i've field on database, ids concatenated comma, these fields umbraco document properties.
for instance, let's i've these entries these fields:
entry 1: relatedcontents: 500,700
entry 2: relatedcontents: 500
my search query fields have value 500, of now, returns entry 2, when use wildcard term using value 500*, returns both of them. fine, problem when searching not begging of value.
when search 700, doesn't return entry 1 , wildcard searches on lucene doesn't allow * @ begging of search term.
it looks query searching values has search term. if there way make query, in analogy, 1 use .contains() search substring in string solve problem, think.
the leading wildcard not supported in lucene design (reference)
if website not complicated , can sure performance not issue, can enable leading wildcard enableleadingwildcards="true"
creating own custom searcher instead of using default 1 in umbraco examine:
define custom searcher in settings:
<add name="customsearchsearcher" type="mynamespace.myumbracoexaminesearcher, mynamespace" analyzer="lucene.net.analysis.whitespaceanalyzer, lucene.net" enableleadingwildcards="true"/>
use rawquery when want search:
var searchprovider = examinemanager.instance.searchprovidercollection["customsearchsearcher"]; var searchcriteria = searchprovider.createsearchcriteria(); searchprovider.search(searchcriteria.rawquery("relatedcontents:*700*));
Comments
Post a Comment