Content query map (SQL select fields)

Hi, coming from SQL I feel the select fields part is missing from query.

I currently work around this by running map on the results.
I suspect running the “map” in elasticsearch would be a lot quicker than running it in my js service/controller…

The search works like this:

query result contains the Id of matching nodes, the nodes are then fetched from storage.

Its not feasible to return the search-fields directly from the search index; these are optimized for searching - not storing the values one to one with the actual node stored on disk.

It could, on the other hand, be possible to map the results from the fetched data; e.g adding a returnFields to the query-API, and do the mapping backend instead, as an alternative to get the full content. I do not think this will improve the performance a lot, but maybe it would be nice for convenience?

What I needed to fetch though, is a list of ids (_name), so maybe that is contained within the search index? And thus will be a lot quicker than fetching the entire content. If there are any values available in the search index, perhaps that would be a new function in content library, or some other library.

I agree that a returnFields parameter on query could be convenient and/or a callback like modify has:
http://repo.enonic.com/public/com/enonic/xp/docs/6.4.2/docs-6.4.2-libdoc.zip!/module-lib_xp_content.html#.modify

If not added to contentLib it could be added to something like utilLib, but seems like it belongs in contentLib. (I’ll leave that up to you :wink:

We could return id’s/paths only, which would speed things up a bit since we dont have to fetch nodes if that is useful. Other data from search-index should not be returned IMO, they are implementation-details that should not be exposed (and they could change at any time)

1 Like

For the low level node API we will most likely support field selector.

We will close this issue for now.