32069

In ElasticSearch(Nest), Can't specify parent if no parent field has been configured

I am using Nest Client to communicate with ElasticSearch.

When i trying to index child type it is giving me error in the heading. I have already set this attribute on Parent Type : [ElasticType(Name ="item", IdProperty = "id")]. This should tell elastic type about id field.

Below is the query made by nest with error info.

{StatusCode: 400, Method: PUT, Url: http://localhost:9200/itemindex/inventory/15894?routing=15894&parent=15894, Request: { "itemId": 15894, "inventories": [ { "storeId": 20693, "inventoryCount": 40 } ] } Response: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Can't specify parent if no parent field has been configured"}],"type":"illegal_argument_exception","reason":"Can't specify parent if no parent field has been configured"},"status":400}}

When i am using this query directly with sense. It is successfully inserting and updating data. But not when i try with Nest.

Please suggest? Any help is appreciated. Thank you in advance.

Could any one explain the reason of this error?

Answer1:

I don't know your index mapping, but looks like you forgot to specify parent when defining mapping for child document.

This is how you can do this with NEST 2.0.0-alpha1.

public class Parent { public int Id { get; set; } public string Name { get; set; } } public class Child { public int Id { get; set; } public string Name { get; set; } } var response = client.CreateIndex(indexName, d => d .Mappings(map => map .Map<Parent>(m => m.AutoMap()) .Map<Child>(m => m.AutoMap().Parent<Parent>())));

Hope it helps.

Recommend

  • Delete from ListBox items in a Loop
  • Prevent duplicates from adding items from Listbox1 to Listbox2 (VBA excel)
  • How to replace numbers with order in (python) list
  • bootstrap css, how to make full width div inside container
  • $lookup from Multiple Collections, and nested output
  • Drag and drop item in same ListView
  • How to get rid of enclosing double-quotes in the expanded `forfiles` variables?
  • How to test method Jsoup.connect (static) using PowerMock?
  • C# helper classes to implement NTLM authorization
  • Ability to use Bootstrap 3 grid system to specify width of select element
  • CORS with socket.io
  • How do I Dispose a HttpResponseMessage in my Web Api Method?
  • mave 3.2 not able to access local nexus instance return 502 code
  • New Firebase failed: First argument must be a valid firebase URL and the path can't contain “.”
  • JSON encode and decode on PHP
  • Building Qt project for C++11 standard
  • Primefaces :radioButton inside a ui:repeat
  • Tomcat memory Leak
  • Can you perform a UNION without a subquery in SQLAlchemy?
  • PostgreSQL Query without WHERE only ORDER BY and LIMIT doesn't use index
  • Cannot resolve symbol 'MyApi'
  • Java: can you cast Class into a specific interface?
  • How to rebase a series of branches?
  • AES padding and writing the ciphertext to a disk file
  • Updating server-side rendering client-side
  • How to extract text from Word files using C#?
  • Trying to switch camera back to front but getting exception
  • Display Images one by one with next and previous functionality
  • Circular dependency while pushing http interceptor
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • SQL merge duplicate rows and join values that are different
  • AngularJs get employee from factory
  • Free memory of cv::Mat loaded using FileStorage API
  • How to set the response of a form post action to a iframe source?
  • Angular 2 constructor injection vs direct access
  • Change div Background jquery
  • Turn off referential integrity in Derby? is it possible?
  • JaxB to read class hierarchy
  • Programmatically clearing map cache