Reputation: 1
In Solr,we have documents with a _root_
field.
The parent and child records are interconnected with _root_
. The _root_
parameter will be the same for the parent and their corresponding children.
The type_string
fields of parents and children are different. We need to do a join on parent and child using root.
How do I do a join between orders and schedulelines
and fetch orders
based on a filter applied to ScheduleLineDetail
for "date"?
{
"id":"7503",
"type_string":"Order",
"_version_":1763406080353763328,
"_root_":"7503"
}
{
"id":"7503_20",
"entryNumber_string":"20",
"type_string":"OrderEntry",
"_root_":"7503"
}
{
"id":"7503_20_null",
"date":"2023-04-20T22:39:18Z",
"type_string":"ScheduleLineDetail",
"_root_":"7503"
}
Upvotes: 0
Views: 112
Reputation: 1248
It can be possible via writing CustomSolrQueryConvertor
and override convertSolrQuery
method.
Example:
public class CustomSolrQueryConvertor extends DefaultSolrQueryConverter implements SolrQueryConverter, BeanFactoryAware {
@override
public SolrQuery convertSolrQuery(SearchQuery searchQuery) throws FacetSearchException {
SolrQuery solrQuery = super.convertSolrQuery(searchQuery);
String dateQuery = "date:"+new Date();
solrQuery.add("fq", "q={!join from=root to=root}type_string:OrderEntry AND"+dateQuery);
}
return solrQuery;
}
Note: This is an example, you need to adjust DATE parameter according to your document or requirement.
Upvotes: 0