Solr how to define subdocuments in schema.xml

I have a document with a document attached and I want to define a schema for Solr. I read the documentation, but don't know how to define schema.xml with attached documents.

When I try to index a document using addBean , I get an error because I don't have an obj1 field in the schema, and I don’t know how to determine it.

I am using a java object with @Field annotations.

 public class ObjToIndex { @Field String id; @Field String name; @Field ObjToIndex2 obj1; public class ObjToIndex2 { @Field String id; @Field String lastName; 

I don’t know how to define the obj1 field with the type “object” or something like that in the circuit.

+6
source share
2 answers

to have a nested object use @Field (child = true)

 public class SolrBeanWithNested{ @Field private String id; @Field(child = true) private MyNestedOject nested; } 

Available with solr 5.1 See Ticket: solr child

-1
source

I believe this is correct:

How to write an attached schema.xml file in solr?

Some logic of the “why” is described here , but the basic concept is that the “child” documents are actually more “connected”, or “related” documents within the same scheme. They can include different fields, but effectively, they simply add to a subset of the fields in the overall schema.

-1
source

Source: https://habr.com/ru/post/989192/


All Articles