Page 1 of 1

Using solr to search products with a specific attribute

Posted: Thu Jun 27, 2013 2:18 pm
by smaris
Hi,

I want to extend the solr schema in order to search for products that have a specific product attribute defined. I don't know for sure if this is possible because a product can have multiple product attributes and I only want to search on a value of a specific product attribute.

I guess I should add a property to the schema.xml like:

Code: Select all

<field name="productAttributes" type="text_general" indexed="true" stored="false" multiValued="true" />


Should I then create a new SearchFacet and use the ProductSearchFacet to search for that specific attribute value?

Code: Select all

List<SearchFacetDTO> availableFacets = searchService.getSearchFacets();
ProductSearchCriteria searchCriteria = facetService.buildSearchCriteria(request, availableFacets);


It would be great if this is possible.

Re: Using solr to search products with a specific attribute

Posted: Mon Jul 01, 2013 5:06 am
by janschraepen
I'm basically struggling with the same issue..

In another forum post, someone mentioned it should be possible that by adding a search facet on productAttributes it should be possible to search a certain productAttribute. However, I wasn't able to get this working..

The forum post:
viewtopic.php?f=11&t=1572&start=0&hilit=productAttributes

I added a record to the BLC_FIELD table with ENTITY_TYPE = PRODUCT and PROPERTY_NAME = productAttribute.attri1. Am I correct when assuming that attri1 is the key of the attribute I'm trying to query?
I also had to add a record to the BLC_FIELD_SEARCH_TYPES table having a reference to my newly created record in BLC_FIELD and with a SEARCHABLE_FIELD_TYPE 't'
Finally, in order to make the field facetable, I created a global search facet record in BLC_SEARCH_FACET. The above steps however didn't have an effect. Searching on a value of an attribute did not work..

Did anyone try this and got this working?
Thx in advance!

Jan

Re: Using solr to search products with a specific attribute

Posted: Tue Jul 09, 2013 9:39 am
by janschraepen
I finally got it working..

I added a record to the BLC_FIELD table with ENTITY_TYPE = PRODUCT, PROPERTY_NAME = productAttribute.attri1 and FACET_FIELD_TYPE set as 's'. attr1 is the "key" of the productAttribute we're trying to query. I also had to add a record to the BLC_FIELD_SEARCH_TYPES table having a reference to my newly created record in BLC_FIELD and with a SEARCHABLE_FIELD_TYPE 't'. Next I've created a global SEARCH_FACET with a LABEL 'Attr1' (the name doesn't really matter) and a link to the newly created record in BLC_FIELD. If desired you could set the SHOW_ON_SEARCH flag on, to see some extra info in the search result. Finally I've applied the facet to the Root category by adding a record to the BLC_SEARCH_FACET_XREF.

If it doens't work right away? Have a look at the interval the Solr indexing ;-)

Jan