Hello,

I have created some products (nodes). Each product is attached (entityReference) to a specific shop, and this shop has an address (adressfield). I have created a default node index, and a view (from the default node index) to list products depending some arguments.

In this view I want to filter products by the postal code of the shops. But, I can't access to the "postal code field" in the contextual filters :

- if I create a relationship to the shop (indexed node, related shop), I get no the relative fields of the shop in the contextual filters : no field address locality, no field adress postal code... With a "default view" based on nodes, if I have a configured relationship, I get additionnal fields in the contextual filters.
- In the node index, I have added an additionnal field (field_address:postal_code / with integer value) and reindexed the nodes. This field appears in my view, but seems not to be populated, it's empty. Then, my contextual filter with this field don't work.

Have you any idea to resolve my problem? Can you give me the process to configure the contextual filter with the postal code?

Thanks.

Comments

kumkum29 created an issue. See original summary.

kumkum29’s picture

Issue summary: View changes
drunken monkey’s picture

Status: Active » Fixed

- In the node index, I have added an additionnal field (field_address:postal_code / with integer value) and reindexed the nodes. This field appears in my view, but seems not to be populated, it's empty. Then, my contextual filter with this field don't work.

If you're indexing products, then you need to index the address field relative to the shop – i.e., add the field field_shop:field_address:postal_code. Otherwise it will try to find the field_address field on the product itself – and fail, of course.

Relationships in Search API views are just for "Fields", not for filters, sorts, etc. For the latter, you just have the indexed fields, and all of those available are already there right away in the view, without adding any relationships.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.