I am trying to set up Examine search on a multilingual site, and the approach I am taking is to add language details to the index, using the GatheringNodeData event. So what I have set up is this:
I have then created my handler to add my custom field:
public class ContentSearchIndexerEvents : ApplicationBase
{
public ContentSearchIndexerEvents()
{
var indexer = ExamineManager.Instance.IndexProviderCollection["MyIndexer"];
indexer.GatheringNodeData += GatheringNodeDataHandler;
}
void GatheringNodeDataHandler(object sender, IndexingNodeDataEventArgs e)
{
INode languageNode = GetLanguageForNode(siteprofileNode); //External method
e.Fields.Add("searchableLanguage", languageNode.Name.ToLower());
}
}
But when I do my search, added "searchableLanguage" field, does not show up in the Fields collection. Is there anything more I need to do here? I debugged through the code, and my event gets hit when I publish a node.
The languageNode Name() that field alias needs to be in the indexuserfields for all the language versions easiest bet would be to leave Indeuserfields blank in the configuration so that all fields are indexed see if that fixes the problem.
Ok, now I got it opened with Luke, and it seems that the fields do exist, at least on the newly created docuements, but they do not show up when I loop the fields in Examine like this:
1: Why are the fields not showing up in list of fields in the code? (And I cannot search them either).
2: How do I force a re-index of all the existing nodes on my site that do not currently have the fields in the index? I tried a recursive publish, but that does not seem to be enough. A manual puplish on each document however does seem to solve it. But a bit annoying.
Adding custom fields to Examine index
Hi all.
I am trying to set up Examine search on a multilingual site, and the approach I am taking is to add language details to the index, using the GatheringNodeData event. So what I have set up is this:
I have then created my handler to add my custom field:
But when I do my search, added "searchableLanguage" field, does not show up in the Fields collection. Is there anything more I need to do here? I debugged through the code, and my event gets hit when I publish a node.
Any hints appreciated.
Morten,
The languageNode Name() that field alias needs to be in the indexuserfields for all the language versions easiest bet would be to leave Indeuserfields blank in the configuration so that all fields are indexed see if that fixes the problem.
Regards
Ismail
Just tried leaving it blank, but it seems to give me the same results as before. Not quite sure what the heck is going on.
what do you see when you view the index with luke is the field there?
Not familiar with Luke. Only seen it mentined a few places. Do I just point to a file (in that cas which one?)
You point it index directory and it will allow you to view and search it
Ok, now I got it opened with Luke, and it seems that the fields do exist, at least on the newly created docuements, but they do not show up when I loop the fields in Examine like this:
Have you tried rebuilding the index using Ismail's examine admin tool?
http://our.umbraco.org/projects/backoffice-extensions/examine-index-admin
Its been a great help for me to do a rebuild without having to publish from Umbraco.
With regards to the fields not showing up: Have you tried doing a search from Luke to see if you get any results there?
- Morten
Didn't know the tool, but will use that for reindexing.
I get 83 results if I do a search in luke like this: searchableSiteProfile:denmark
But this code returns no results from examine:
Morten,
In your configuration what analyser you using ? Also in your code after the line
can you write searchCriteria.ToString() that will display the query examine is running then paste that query and luke and see what you get.
Regards
Ismail
Hi Ismail.
Im using this:
The ToString gives me this output: '{ SearchIndexType: , LuceneQuery: +searchableSiteProfile:denmark }'
Pasting that query to Luke gives me 83 results, but in my code, searchResults.TotalItemCount is 0.
Facepalm moment!
I was executing the serach against the default searcher instead of my own searcher. The last line should be:
Thanks for all the help. Now I get the expected results!
is working on a reply...