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.

qwtel
  • 4,467
  • 1
  • 18
  • 12

1 Answers1

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'] }] })
qwtel
  • 4,467
  • 1
  • 18
  • 12