2

Is there a way to create an index for an array property of a document, so that I can Match the document based on any value in the array?

For example, assuming a document looks something like

{ data: { ips: ['192.168.1.1', '::ffff:c0a8:101'] } }

then I'd like to have an index documents_by_ip s.t. I can retrieve that document with either 192.168.1.1 or ::ffff:c0a8:101.

1 Answer 1

2

I was able to answer this question before even posting it. There are no extra steps required, just adding a field that is an array to the index terms will do exactly what I wanted to ~~~

CreateIndex('documents_by_id', { terms: [{ field: ['data', 'ips'] }] })
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.