How to Configure Solr to Search for Other Entities
Posted: Tue Jun 10, 2014 6:12 am
BLC Solr search extension seems product centric. I tried to configure search for other entity types such as deal/promotion, but couldn't get it to work. Here is what I've done:
1. Add necessary records for the new entity to following search related tables:
1) BLC_FIELD;
2) BLC_FIELD_SEARCH_TYPES
3) BLC_SEARCH_FACET
4) BLC_SEARCH_FACET_RANGE
2. Extend SearchFacetDao to support read facets by entity type
3. Extend SolrSearchService and add following methods
1) getSearchFacets(String entityType)
2) findDealByQuery
3) Other necessary internal methods
4. Extend BroadleafSearchController to support search for different entity types
All above code changes take effect, but the search doesn't work. The problem is in SolrSearchServiceImpl.setFacetResults. FacetField facet.getValues is null and for (Count value : facet.getValues()) doesn't check for it:
Am I missing anything? Do the records in BLC_FIELD control what Solr will index?
Thank you!
-Charlie
1. Add necessary records for the new entity to following search related tables:
1) BLC_FIELD;
2) BLC_FIELD_SEARCH_TYPES
3) BLC_SEARCH_FACET
4) BLC_SEARCH_FACET_RANGE
2. Extend SearchFacetDao to support read facets by entity type
3. Extend SolrSearchService and add following methods
1) getSearchFacets(String entityType)
2) findDealByQuery
3) Other necessary internal methods
4. Extend BroadleafSearchController to support search for different entity types
All above code changes take effect, but the search doesn't work. The problem is in SolrSearchServiceImpl.setFacetResults. FacetField facet.getValues is null and for (Count value : facet.getValues()) doesn't check for it:
Code: Select all
protected void setFacetResults(Map<String, SearchFacetDTO> namedFacetMap, QueryResponse response) {
if (response.getFacetFields() != null) {
for (FacetField facet : response.getFacetFields()) {
String facetFieldName = facet.getName();
SearchFacetDTO facetDTO = namedFacetMap.get(facetFieldName);
for (Count value : facet.getValues()) {
SearchFacetResultDTO resultDTO = new SearchFacetResultDTO();
resultDTO.setFacet(facetDTO.getFacet());
resultDTO.setQuantity(new Long(value.getCount()).intValue());
resultDTO.setValue(value.getName());
facetDTO.getFacetValues().add(resultDTO);
}
}
}
Am I missing anything? Do the records in BLC_FIELD control what Solr will index?
Thank you!
-Charlie