I have several JSON like that :
The Universal Index should have the information you need.
Edit to expand on my answer:
Both solutions you mentioned require storing additional information. In the case described, the Universal Index already has the information you need, making it the preferred solution. This approach would stop being my preferred choice if the jsonPropertyValueQuery became ambiguous; that is, if there was more than one
type property per document. In that case, the query would match against any of the
If that were the case, putting a JSON property range index on the
type property wouldn't help, as the range index would still contain all instances of the
To handle multiple types within a document you would have two choices:
Of the two, I like the first. It's flexible -- you can use it even if you have documents with different structures in your database. In that way, it may "future proof" your project. The tradeoff is that your code needs to manage your documents' collections when doing an insert. That's pretty simple to do though.
In terms of performance, either of these approaches will do well with queries, but option two will have slightly more work to do during indexing. MarkLogic will need to check whether the configured path exists in a document, and if so, update the index accordingly. That's a minor difference, but has potential to add up.