Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
This seems like a bug - I would expect it to work based on your attempted troubleshooting steps and the code.
If I remember correctly, you should be able to work around this by using a FieldQuery with lucene syntax: "field: value" in the query expression. If you take a look at the index in Luke, you can grab the field name for the category.
Edit: I just remembered that the query expression syntax doesn't work as a pass through, that is in Commerce. Ted Nyberg has an example of a CustomFieldQuery to be able to pass in the field you wish to scope your FieldQuery to - the example is in this article as "CustomFieldQuery": http://tedgustaf.com/blog/2013/4/add-custom-fields-to-the-episerver-search-index-with-episerver-7/
Pasted below for redundancy - all credit to Ted.
public class CustomFieldQuery : IQueryExpression { public CustomFieldQuery(string queryExpression, string fieldName) { Expression = queryExpression; Field = fieldName; Boost = null; } public CustomFieldQuery(string queryExpression, string fieldName, float boost) { Expression = queryExpression; Field = fieldName; Boost = boost; } public string GetQueryExpression() { return string.Format("{0}:({1}{2})", Field, LuceneHelpers.EscapeParenthesis(Expression), Boost.HasValue ? string.Concat("^", Boost.Value.ToString(CultureInfo.InvariantCulture).Replace(",", ".")) : string.Empty ); } public string Field { get; set; } public string Expression { get; set; } public float? Boost { get; set; } }
Hope this helps,
/Matt
Thanks you.
I am aware of the Ted's blog post regarding custom fields in Lucene, and I might use that approch. But I would prefer to use the built in category field query.
I'll reach out to Epi-support and see what they have to say.
When looking at the index in Luke, I noticed that it is the CategoryId that is saved, not the Category value.
I was able to get it working by passing the category ID instead, by using CategoryRepository like so:
var categoryRepository = ServiceLocator.Current.GetInstance<CategoryRepository>(); var myCategory = categoryRepository.Get("Something"); categoryQuery.Items.Add(myCategory.ID.ToString());
Hi,
I'm trying including categories in Episerver Search, but I'm having some issues getting any hits. I currently have this:
In the query expression I'm currently only including the category query. But when doing the actual search I'm getting zero hits.
I know the search is working, as I am able to search for freetext via:
This is what I've tried so far:
I'm starting to thinking that my query syntax may be wrong?