Plone REST API - Filtering search results using a value inside an object

I am trying to use @search or @querystring-search endpoints to limit the response to include only items with priority.token = 1.

An item includes a priority object as follows:

"priority": {
    "title": "1 Important",
    "token": "1"
}

Using @search endpoint, I tried adding priority.token=1, but that resulted in this error:

"Query for index <FieldIndex at priority> is missing a 'query' key!"

So, is it possible to filter the results using a value inside an object? And how to do that?

This is not how searching and indexing in Plone works.
If you want to search for token, you need to create a FieldIndex token and a related indexer that would index the token attribute of priority objects. Same for title which would be a fulltext index.

1 Like

Try skipping the token, search for just fow what priority returns ( probably either 1 or '1 Importanr' )

That does not work either.

Show code

Not helpful....please provide information about your data model, implementation, catalog setup and your indexer implementation.

@AbdallahElYaddak what is the schema definition for your object?
Sounds like you are using some kind of compound field.
I don't think there is an index type that would work out of the box index for this.
If you have custom code on your content type then you can have something like

@property
def priority_token(self):
   return self.priority['token']

and then add a field index called priority_token

and then you can search using "priority_token=1".

basically search is like BigTable, it's flattened data model for search.

It would be nice though if FieldIndex did allow you traverse inside dicts or subobjects...