I was given a task to introduce solr to our product so I thought about spring-data-solr. I have seen this blog: http://www.petrikainulainen.net/spring-data-jpa-tutorial/
and I was able to run embedded solr in integration test. Since I have a simple POC I wanted to make it more advanced to see whether it fits our needs. So I started to search for mapping nested objects. I found this: https://stackoverflow.com/questions/30561245/is-is-possible-to-use-embeddables-in-spring-data-solr
Someone answered that version 1.4.0 did not support nested objects. Anyone knows whether it changed? These links look promising:
- https://dzone.com/articles/using-solr-49-new
- Solr: Indexing nested Documents via DIH
- https://issues.apache.org/jira/browse/SOLR-1945
So, wrapping up, here is a list of my questions:
- Is it possible to map parent-child relation? (on one level at least?)
- If you answered 'no' to first question - then how can I flatten child's fields to be part of solr's document? Should I register some kind of converter somehow? Is there anything else I should do?
- I found also this: http://docs.spring.io/spring-data/solr/docs/current/api/org/springframework/data/solr/core/mapping/Indexed.html What is the purpose of this annotation? So far I have seen example with @Id and @Field annotations only. Is it used to generate schema based on model maybe? If so then how can I do that?
- Last, but not least - when I create a SolrRepository should I use my JPA entity (annotated with @Fields annotations) as a generic type? Or rather should I create a totally different POJO which should be a view/dto of my jpa entity? This question is again about conversion I guess. If I create a dedicated POJO than I can convert/map fields manually in constructor, but this feels rather bad idea.