November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Could you change the Type property to be of type List
client.Conventions.ForInstancesOf().IncludeField(x => x.Type.Split(','));
client.Search().TermsFacetFor(x => x.Type.Split(','));
Remember to put the first line of code in an initialization module or similar, and that you will need to reindex.
Is this line for intialization module?
client.Conventions.ForInstancesOf
Yes, but I now realize that it may not be the case. It depends on how you are indexing your objects. Had this been standard PageData, the correct way would be to use an initializeable module and the SearchClient.Instance client object. However, since this is a custom object, I suppose you are indexing it on your own. All you need to do then is to make sure that you set up the conventions (the first line of code in my previous post) before you index your object, and also make sure that you set up the conventions for the same client object as you are doing the indexing with. I hope that makes sense! :-)
Thanks Per,
Its an Episerver Commerce Project with EpiServer Find. and is based on ProductContent, I will be thankful if you can do any further help.
public class BookProduct : EPiServer.Commerce.Catalog.ContentTypes.ProductContent
{
public virtual string Formats //data will be Hardback, Digital Download
}
I am using Jonas Solution for Indexing data Indexing Catalog Contents
I have already got understanding of your opinion and tried that but It was giving me this error on Indexing. I know it is due to data issue but I dont know what to do with this.
public void Initialize(InitializationEngine context)
{
SearchClient.Instance.Conventions.ForInstancesOf
SearchClient.Instance.Conventions.ForInstancesOf
SearchClient.Instance.Conventions.ForInstancesOf
CatalogRouteHelper.MapDefaultHierarchialRouter(RouteTable.Routes, false);
}
On Indexing job I got below error
ERROR EPiServer.Find.Cms.ContentIndexer - An exception occured while indexing (Batch): Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at lambda_method(Closure , ProductContent )
at EPiServer.Find.DelegateValueProvider`2.GetValue(Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at EPiServer.Find.Api.BulkActionConverter.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at EPiServer.Find.Json.Serializer.SerializeToStringBuilder(JsonSerializer serializer, Object value, StringBuilder buffer)
at EPiServer.Find.Api.BulkCommand.Execute()
at EPiServer.Find.Client.Index(IEnumerable objectsToIndex)
at EPiServer.Find.Cms.ContentIndexer.IndexWithRetry(IContent[] contents, Int32 maxRetries)
at EPiServer.Find.Cms.ContentIndexer.Index(IEnumerable`1 content, IndexOptions options)
at EPiServer.Find.Cms.ContentIndexer.<>c__DisplayClass16.
Regards
Khurram
Hi,
I'm guessing you may have some null values. To get around that, you could do this instead:
SearchClient.Instance.Conventions.ForInstancesOf().IncludeField(x => x.TypeAsList());
and then create a corresponding extension method
public static string[] TypeAsList(this Product product)
{
if(!string.IsNullOrEmpty(product.Type))
{
return product.Type.Split(',');
}
return null;
}
After running the indexing, you index should be populated with the correct values. Something like this:
"TypeAsList": [
"something",
"blabla",
"something else"
],
You could then do
.TermsFacetFor(x => x.TypeAsList())
Hi,
Class Product{
string Type = "Hardback, Paperback, CD, Digital Download, Toys"
}
My data is indexing based on near about above type of object.
Indexed data is something like this $Type : "Hardback, Paperback, CD, Digital Download, Toys"
using TermsFacetForWordsIn in my query I get following results
Hardback(1),
Paperback(1),
CD(1),
Digital(1)
Download(1),
Toys(1)
using
TermsFacetFor
returns me whole string Hardback, Paperback, CD, Digital Download, Toys(1)
My desiresd resulset should be
Hardback(1),
Paperback(1),
CD(1),
Digital Download(1),
Toys(1)
How should i write the query?
Regards
Khurram