Update
well turns out my configuration was just not working, i reverted back to using the defaultindexconfiguration from the contentsearch definitions by sitecore.
once i did that, everything worked magically. i just added template conditions to my queries and all is good.
been banging my head at this for 2 days now and i'm getting no where.
The scenario:
I have articles that are tagged with items from a tree/multilist.
I have an index defined to look throughout my site for a particular template type, and then store some values (name, description, path, tags). This index uses a small indexConfiguration. I am avoiding the default index configuration as that one bloats up my indexes too much, i just need a slim set of results.
<myConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneSearchConfiguration, Sitecore.ContentSearch.LuceneProvider">
<defaultIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider">
<indexAllFields>true</indexAllFields>
<Analyzer ref="contentSearch/configuration/defaultIndexConfiguration/analyzer" />
<fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch">
<fieldNames hint="raw:AddFieldByFieldName">
<field fieldName="Article Tags" storageType="yes" indexType="tokenized" vectorType="no" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
<field fieldName="Teaser Title" storageType="yes" indexType="tokenized" vectorType="no" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
<field fieldName="Teaser Description" storageType="yes" indexType="tokenized" vectorType="no" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
<field fieldName="Article Date" storageType="yes" indexType="tokenized" vectorType="no" boost="1f" type="System.DateTime" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
<field fieldName="Views" storageType="yes" indexType="tokenized" vectorType="no" boost="1f" type="System.Int32" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
<field fieldName="__Workflow state" storageType="yes" indexType="untokenized" vectorType="no" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
</fieldNames>
</fieldMap>
<fields hint="raw:AddComputedIndexField">
<field fieldName="isfinal" storageType="yes" indexType="tokenized">Core.Search.ComputedWorkflowState, Core</field>
<field fieldName="Teaser Image" storageType="yes" indexType="tokenized">Core.Search.ComputedTeaserImage, Core</field>
<field fieldName="Article Url" storageType="yes" indexType="tokenized">Core.Search.ComputeUrl, Core</field>
</fields>
<include hint="list:IncludeTemplate">
<articlePage>{28432890-0F71-4E2F-8577-7848F90FCBCC}</articlePage>
</include>
</defaultIndexConfiguration>
</myConfiguration>
By looking at the index using Luke, i can see the tags are indexed properly. each tag has its own row in the document.
I create a class(ArticleItem) that extends SearchResultItem, and then i implemented the appropriate attributes with decoration.
[IndexField("article_tags")]
public List<ID> tags{get;set;}
Now i try to make a query using sitecore linq, and a predicate builder.
using (var context = ContentSearchManager.GetIndex(indexName).CreateSearchContext())
{
IQueryable<ArticleItem> query = context.GetQueryable<ArticleItem>();
var predicate = PredicateBuilder.True<ArticleItem>();
foreach (var id in tags)
{
var tempTerm = id;
predicate = predicate.Or(p => p.Tags.Contains(id));
}
var results = context.GetQueryable<ArticleItem>().Where(predicate).GetResults();
if (results != null)
{
if (results.Hits.Any())
{
return results.Hits.Select(x => x.Document);
}
}
}
when i call context.GetQueryable() by itself, then iterate through the results, the tags are all present, and there are definitely matches.
have i misconfigured something?
*additional information
testing the search with the additional queries: p.Tags.Contains("3") doesnt return any results (there is definitely an item with a guid that contains the char 3.
my termcount for article tags is 0 when looking via luke.
by turning the field into a computed field, my search results are now working (although the values are stored as an entire string instead of being tokenized) and the term counts are appearing.