for (i = 0; i < phrasedKeyword.Length; i++) { filter.And().GroupedOr(
new string[] { "nodeName", "alternativeTitle", "introText", "bodyText", "metaDescription", "metaKeywords", "FileTextContent" }, new IExamineValue[] { phrasedKeyword[i].MultipleCharacterWildcard() }
); }
If I search using just 'cat' or 'dog' or 'cats' or 'cats dogs' the correct page is found. As soon as I introduce the word 'and' e.g. 'cats and dogs' the page is no longer returned in the results.
I know words like and, a, I etc. get sripped out when the indeing is performed but how can I make the search work if they are entered by the user?
I had the thought that if Examine removes common 'non-useful' words like 'and', 'I', 'a' should I be removing them from the user's search query string first?
Matt, if you follow the steps in the linked page above to extend the StandardAnalyzer, and use a stopWords file that has the words you need removed, your phrase searches with e.g. 'and' will work. After many hours of messing I finally got mine sorted - hopefully the info can save you the pain!
Examine MultipleCharacterWildcard search and the word 'and'
I have the following string in the content of one of my pages:
"The cats and dogs sleep."
and the folowing code to perform the MultipleCharacterWildcard examine search:
string keyword = "cats and dogs";
string[] phrasedKeyword = SplitQueryWithQualifiers(keyword, ' ', '\"', true);
//generate Search Criterea
m_Searcher = ExamineManager.Instance.SearchProviderCollection["myindexToSearch"];
Examine.SearchCriteria.IBooleanOperation filter;
var criteria = m_Searcher.CreateSearchCriteria(IndexTypes.Content, Examine.SearchCriteria.BooleanOperation.Or);
if (keyword != "")
{
filter = criteria.Field("umbracoNaviHide", "0");
}
else
{
filter = null;
}
for (i = 0; i < phrasedKeyword.Length; i++)
{
filter.And().GroupedOr(
new string[]
{
"nodeName",
"alternativeTitle",
"introText",
"bodyText",
"metaDescription",
"metaKeywords",
"FileTextContent"
},
new IExamineValue[]
{
phrasedKeyword[i].MultipleCharacterWildcard()
}
);
}
If I search using just 'cat' or 'dog' or 'cats' or 'cats dogs' the correct page is found.
As soon as I introduce the word 'and' e.g. 'cats and dogs' the page is no longer returned in the results.
I know words like and, a, I etc. get sripped out when the indeing is performed but how can I make the search work if they are entered by the user?
I had the thought that if Examine removes common 'non-useful' words like 'and', 'I', 'a' should I be removing them from the user's search query string first?
Thanks,
Matt
Guys,
See http://our.umbraco.org/forum/developers/extending-umbraco/25600-Examine-case-insensitive-keyword-search
Regards
Ismail
Thanks for that link Ismail,
I'll take a look and see if it's what I need.
Cheers, Matt
Matt, if you follow the steps in the linked page above to extend the StandardAnalyzer, and use a stopWords file that has the words you need removed, your phrase searches with e.g. 'and' will work. After many hours of messing I finally got mine sorted - hopefully the info can save you the pain!
Thanks for that guys. All is rosey now. :-)
is working on a reply...