How to create a search for only one context


(Charlotte Westney) #1

Matrix Version: 5.3.4.0

Hi everyone,

We have some sites that run with 2 context, English and Welsh. They have simple search on them, but we’d like to be able to set that so that when you are in Welsh context it only searches and brings back results from the welsh context page contents.
http://www.eryri-npa.gov.uk/cym/home

I’m sure that must be possible with some kind of setting in the search, right?
Anyone know what that is?

Thanks!
Charlie


(Douglas (@finnatic at @waikato)) #2

https://matrix.squiz.net/manuals/contexts/chapters/what-are-contexts reinforces the idea that should be possible:

“Listing assets (such as an Asset Listing, Search Page or Site Map) are able to return results stored against a specific context.”

but I’m stumped as to what screens for asset listings or search pages (which we use a lot) reference contexts.

Bart?


(Bart Banda) #3

It looks like it actually already does bring back results from the Welsh context.

For example, if I search for “Prydain”
http://www.eryri-npa.gov.uk/cym/search/search-results?queries_term_query=Prydain

I get Welsh content pages in the results, the first result has several mentions of that word in it so we can assume it’s done a search for that content in Welsh, as the English version doesn’t have a single mention.

Is it just that your search results type format is showing the English Context Name and Description?

For name for example, try using %asset_attribute_name% instead of %asset_name% as I think that will print the contextual version correctly.


(Charlotte Westney) #4

Hi Bart,

Sorry I should have been clearer in my question. It does bring back results from both contexts, but what we’d like is to be able to have the search only bring back English context when you search from a page currently showing that context. And then only bring back Welsh context results when you search from a page currently showing that context. At the moment it brings back both contexts on both.

Does that make better sense?!
Thanks,
Charlie.


(Bart Banda) #5

Hmm, I’m not sure that would be possible. That might also make your search miss some results if you have pages that are not contextualised? Is that what you essentially want?

One thing you might be able to do is to have a metadata field that controls this, might have to be manually edited though because you would want to populate it with a Welsh value if your page has been contextualised for Welsh, and have English as the default value. Your search page could then search for this field automatically based on the Context you are in, automatically pass to it the context name so that results need to match on that metadata field.

I’m still not sure if that’s what you are after?


(Tbaatar) #6

Hi Charlotte,

I think it is more then likely the way you have setup the Search Field for your Search Page asset. I have exactly similar setup and I’m able to produce what you want without any hack or trickery.

For example in German context, it will only show results for that context and not show results from English, Spanish, French or Danish. The same for the other contexts.