Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Just-In-Timeberlake
Aug 18, 2003
So this is the closest thread I can find that has to do with elastic search, I have a couple of questions that I can't find a definitive answer to regarding arrays and searchability.

I'm looking to offload some invoice data to elastic for searching purposes, and I have a couple of fields that I want to represent as a simple array.

One would be a payment confirmation #, and a customer could potentially pay an invoice off in more than one payment. So the my plan for the field would be for it to look like this "confirmation_numbers": [12345, etc]

Is that a searchable field like that or do I need to mark it nested?

Related to that, I then want an array field with all the payment dates, so something like "payment_dates": ["date1", "date2", etc]

A. is that field able to be defined as a date type, and B) is that field searchable using "from" and "to" with that layout.

Adbot
ADBOT LOVES YOU

Just-In-Timeberlake
Aug 18, 2003

Arcsech posted:

Elasticsearch doesn't make a distinction between single-value and array fields, so "conf_num": 1234 and "conf_num": [1234, 5678] both have the same mapping/schema and you can have some docs with a single value and some docs with an array in the same index.

The main thing to be aware of is with array-valued fields, order is not considered when searching, so you could query for "conf_num:5678 AND conf_num:1234", but you can't specify in the search that 1234 has to come before 5678 in the array. You'll want to use a range query for from/to queries, but keeping in mind the above, a range query will return all docs that where any of the values in the "payment_dates" array fall into that range.

thanks, just what I was looking for.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply