Hello,
I don’t find a way to make a search query with sub-selectors. I mean to be able to search for items by matching metadata present in linked items. I would like to be able to do that with the regular page search. Is it possible? Does a module do that? Is it necessary to make two consecutive calls to the api?
For example, I have two templates :
Template “Town”:
- dcterms:title/Name
- dcterms:spatial/State
Template “Building”:
- dcterms:title/Name
- dcterms:creator/Architect
- dcterms:relation/Town (item resource)
And I have two items :
Item “Chicago”:
- template: “Town”
- dcterms:title/Name: Chicago
- dcterms:spatial/State: Illinois
There are also other building items with dcterms:spatial/State: “Illinois”.
Item “860–880 Lake Shore Drive”:
- template: “Building”
- dcterms:title/Name: “860–880 Lake Shore Drive”
- dcterms:creator/Architect: “Ludwig Mies van der Rohe”
- dcterms:relation/Town: “Chicago” (item resource)
There are also other building items with dcterms:creator/Architect: “Ludwig Mies van der Rohe”.
Is it possible on Omeka S to search item like this : any buildings in Illinois made by Ludwig Mies van der Rohe?
With the regular search page, the query would be `dcterms:spatial=Illinois and dcterms:creator=Ludwig Mies van der Rohe`. If the joiner is “AND” I have no results. If the joiner is “OR” I have buildings made by Mies van der Rohe in Chicago and not in Chicago, and I have the item Chicago plus other towns in Illinois.
With the CMS ProcessWire, it is easy to do that, as explained here: Using selectors in ProcessWire CMS . This is what i am looking for. In ProcessWire, the query would be: “template=Building, dcterms:creator=Ludwig Mies van der Rohe, dcterms:relation=[dcterms:spatial=Chicago]”
Thanks,
Vincent
I mean to be able to search for items by matching metadata present in linked items.
Core search can do this only with the linked item’s title. When a value links to another item, text searches on that property also match that item’s title, so you can find Mies buildings in Chicago:
/api/items?resource_template_id={Building template ID}
&property[0][property]=dcterms:creator&property[0][type]=eq&property[0][text]=Ludwig Mies van der Rohe
&property[1][joiner]=and&property[1][property]=dcterms:relation&property[1][type]=eq&property[1][text]=Chicago
But you can’t find Mies buildings in Illinois, because the state isn’t the town’s title.
The simplest workaround is to add the state to each building. Then the AND search you tried works as is.
If you’d rather keep the state only on towns, you’ll need a script or your own module that makes two consecutive searches:
- Search for buildings whose architect (
dcterms:creator) is Ludwig Mies van der Rohe.
- Collect their town IDs from the
value_resource_id of each building’s dcterms:relation value.
- Search for towns with those IDs (
id[]) whose state (dcterms:spatial) is Illinois.
- From the buildings in step 1, keep those whose town ID is one of the towns returned in step 3.
If you’re open to a module, AdvancedSearch adds a search type that does this in one query, though it isn’t in the site search form by default.
Thank you for your reply Jim.
I’ve installed Advanced search module and now I can search with sub-query by using the “resq”/“is resource matching query” operator. Here is the query:
dcterms:creator | in | rohe
and
dcterms:relation | resq | dcterms:spatial=Illinois
“dcterms:spatial=Illinois” works but I will do further tests to see if and how I can pass more complex operators such as “in” or “eq” instead of “=”. Also, I will test if it is possible to pass a sub-query by typing the property label, like “Spatial coverage=Illinois”. If you know how to do it, please let me know.
Vincent