Combined Examine index containing media, content, members
I would like to create a single queryable index that stores some basic properties of media, members and content. Is this feasible? Or do I need to combine the reuslts of different queries.
searcher = WebHelpers.GetMultiSearcher(new[] {"index1", "index2"}); //replace with your indexers
public static MultiIndexSearcher GetMultiSearcher(string[] indexes)
{
var directories = new List<DirectoryInfo>();
foreach (var index in indexes)
{
var indexer = ExamineManager.Instance.IndexProviderCollection[index];
var dir = new DirectoryInfo(((LuceneIndexer)indexer).LuceneIndexFolder.FullName.Replace("\\Index",""));
directories.Add(dir);
}
var i = new MultiIndexSearcher(directories, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29));
return i;
}
The method i have to get the indexers is not optimal sure there is a better way of getting the directories on the bit (LuceneIndexer)indexer) im sure if you cast it to UmbracoBaseIndexer you can get the directory path of index? Anyhow what I have definately works as I am using it on a site where I am searching across umbraco and database indexes.
Also what you may want todo to make queries less terse is use GatheringNodeData event on each index and munge all the fields into new field called content then your query will be short and sweet!
Combined Examine index containing media, content, members
I would like to create a single queryable index that stores some basic properties of media, members and content. Is this feasible? Or do I need to combine the reuslts of different queries.
I think you would need to create a custom indexer. Maybe take a look at the source of the existing ones:
http://examine.codeplex.com/SourceControl/changeset/view/fc526605aab6#Projects%2fUmbracoExamine%2fUmbracoMemberIndexer.cs
With a custom indexer, you could store a common set of fields for all types, and then use that to do your query.
Barry,
You need todo a multi index search
private MultiIndexSearcher searcher;
searcher = WebHelpers.GetMultiSearcher(new[] {"index1", "index2"}); //replace with your indexers
public static MultiIndexSearcher GetMultiSearcher(string[] indexes)
{
var directories = new List<DirectoryInfo>();
foreach (var index in indexes)
{
var indexer = ExamineManager.Instance.IndexProviderCollection[index];
var dir = new DirectoryInfo(((LuceneIndexer)indexer).LuceneIndexFolder.FullName.Replace("\\Index",""));
directories.Add(dir);
}
var i = new MultiIndexSearcher(directories, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29));
return i;
}
The method i have to get the indexers is not optimal sure there is a better way of getting the directories on the bit (LuceneIndexer)indexer) im sure if you cast it to UmbracoBaseIndexer you can get the directory path of index? Anyhow what I have definately works as I am using it on a site where I am searching across umbraco and database indexes.
Also what you may want todo to make queries less terse is use GatheringNodeData event on each index and munge all the fields into new field called content then your query will be short and sweet!
Regards
Ismail
Hello Ismail,
I am trying to do something similar as Barry described, please see this topic
http://stackoverflow.com/questions/21710897/umbraco-fulltextsearch-including-search-of-media-section/21745080?noredirect=1#21745080
Can you give me some pointers, I am lost over here;(
All the best, Adi
is working on a reply...