Hi,
Can you verify that the list of objects that you are passing when indexing is not empty?
Regards,
Henrik
Most likely because the list is empty or your key is not authorized. Your index might be removed due to the developer index expiring or you are not using the correct key.
I am newer in find. Everithing done according documentation. Nothing null list not empty and even i try to index one item i get error:
Object does not match target type.
at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IWrappedCollection values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IWrappedCollection values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
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)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value)
at EPiServer.Find.Json.Serializer.SerializeToStringBuilder(JsonSerializer serializer, Object value, StringBuilder buffer)
at EPiServer.Find.Json.Serializer.Serialize(JsonSerializer serializer, Object value)
at EPiServer.Find.Api.IndexCommand.Execute()
at EPiServer.Find.Client.Index(Object objectToIndex, Action`1 commandAction)
at EPiServer.Find.Client.Index(Object objectToIndex)
As i found episerver find cannot index episerver pages(classes inherited from PageData), only "simple" classes. Is it true?
can:
public class SearchResultItem
{
public string Title { get; private set; }
public DateTime Date { get; private set; }
public string Description { get; private set; }
}
cannnot:
public class SearchResultItem : PageData
{
public virtual string Title { get; private set; }
public virtual DateTime Date { get; private set; }
public virtual string Description { get; private set; }
}
No that is definatly not true.
But since PageData is a very complex object with lots of references this is handled by a separate indexer. May I ask what you are trying to do since it seems you are doing it backwards...
Then you run the indexing job located as a scheduled job. Thats it.
After that pages will be indexed automatically when they are changed and published. You can read more about it here. http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-Find1/75/Integration/EPiServer-7-CMS/Scheduled-job-for-indexing/
I will try,
my errors:
case1
var pages = ContentLocater.Locate.GetDescendents(Context.StartPage.ContentLink).ToList();
// pages are list<ContentReference>
var result = FindClient.Index(pages);
error1:
The remote server returned an error: (403) Forbidden.
Your key is not authorized to access (POST) '/_bulk'
Case2
//Context.Settings.SearchResultPage is page inherit from PageData
var r = FindClient.Index(Context.Settings.SearchResultPage)
Error1
Object does not match target type.
Case3
//GetResults(SearchTerms.GetCurrent()) - list simple classes (not inherit from PageData)
var result = FindClient.Index(GetResults(SearchTerms.GetCurrent()))
Greate work
job works great, thank. But when i try to search i get error:
code: FindClient.Search<SitePageData>(searchLanguage).For(terms.SearchKey).GetResult()
errror:
at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CalculatePropertyDetails(JsonProperty property, JsonConverter& propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target, Boolean& useExistingValue, Object& currentValue, JsonContract& propertyContract, Boolean& gottenCurrentValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at EPiServer.Find.Api.SearchHitConverter.PopulateItemProperty(JsonReader reader, JsonSerializer serializer, Type objectType, Object item)
at EPiServer.Find.Api.SearchHitConverter.PopulateProperty(JsonReader reader, JsonSerializer serializer, Type objectType, String propertyName, Object item)
at EPiServer.Find.Json.IgnoredPropertiesHandlingConverterBase.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IWrappedCollection wrappedList, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
at EPiServer.Find.Api.Command.GetResponse[TResult](IJsonRequest request)
at EPiServer.Find.Api.SearchCommand`1.Execute()
at EPiServer.Find.Client.Search[TSource](SearchRequestBody requestBody, Action`1 commandAction)
at EPiServer.Find.SearchExtensions.GetResult[TResult](ISearch`1 search)
You can read here_ http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-Find1/75/Integration/EPiServer-7-CMS/GetContentResult-and-GetFilesResult/
Also use the SearchClient.Instance in the cms use case
one more question:
1. is there way if i search for "product" i will see results also for "products", "producting" and so on
2. is there way to get text around search key "product"
code: SearchClient.Instance.Search<IContent>().For(terms.SearchKey)
All of the sudden I get this error when trying to index things in Find:
"[The remote server returned an error: (403) Forbidden. Your key is not authorized to access (POST) '/_bulk']".
I'm using the private key and have not changed anything except my code. I have also tried to clear the index.
Anyone have any ideas?
</Jonas>