English 中文(简体)
Sitecore Lucene indexing - save child field values in parent Lucene doc
原标题:

I have a Sitecore content structure where any single item can have a number of child items that are used to store enumerable content for lists (obviously a fairly standard approach). I am hoping to index these items but store their index data against the parent doc in Lucene. This should hopefully speed up the search bit, by saving time sorting through multiple results which all effectively point to the same URL. Below is some basic code for the custom indexer I will implement.

Can anyone let me know if this is (a) possible and (b) a good idea? The main issues I see are that the Lucene doc already looks like it has been created - do I need to delete it? Also, if the Lucene doc for the parent item does not exist, do I need to create it? And will it be overwritten/lost when the parent item is indexed. Looks like a bit of room of conflict there.

Another option is that I don t index child items, but get their values when I am indexing the parent. Now that I think about it, this seems like the better way to go.. opinions?

public class CustomIndex : Sitecore.Data.Indexing.Index
{
    public CustomIndex(string indexName): base(indexName) {}

    protected override void AddFields(Item item, Document document)
    {
        //is item a sub-item (promo item)
        if (...)
        {
            //delete the sub-item lucene doc
            DeleteDoc(document); //is this possible or needed?

            //get parent item
            Item parentItem = item.Parent;

            //get lucene document for parent item
            Document parentDoc = GetParentDoc();

            //add fields to parent item lucene document
            parentDoc.Add(...);
            parentDoc.Add(...);
        }
        else
        {
            base.AddFields(item, document);
        }
    }
}
最佳回答

yes i agree, option #2 is better - index the children when you re at the parent. mainly because you aren t guaranteed what order the traversal will happen in, so the document may get re-created as you said.

问题回答

暂无回答




相关问题
adding an index to sql server

I have a query that gets run often. its a dynmaic sql query because the sort by changes. SELECT userID, ROW_NUMBER(OVER created) as rownumber from users where divisionID = @divisionID and ...

Linq to SQL nvarchar problem

I have discovered a huge performance problem in Linq to SQL. When selecting from a table using strings, the parameters passed to sql server are always nvarchar, even when the sql table is a varchar. ...

TableView oval button for Index/counts

Can someone help me create an index/count button for a UITableView, like this one? iTunes http://img.skitch.com/20091107-nwyci84114dxg76wshqwgtauwn.preview.jpg Is there an Apple example, or other ...

Move or copy an entity to another kind

Is there a way to move an entity to another kind in appengine. Say you have a kind defines, and you want to keep a record of deleted entities of that kind. But you want to separate the storage of ...

热门标签