Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
How to aggregate combinations / permutations in elasticsearch

Is there a possibility to aggregate combinations or permutations in elasticsearch of a single field per document?

Example for combinations for 1 row:

keyword_field : ["test", "array", "for", "combinations"]

<-- aggregate -->

[
  [ 'test', 'array' ],
  [ 'test', 'for' ],
  [ 'test', 'combinations' ],
  [ 'array', 'for' ],
  [ 'array', 'combinations' ],
  [ 'for', 'combinations' ]
]

I want to calculate how often words appear together in a document. Therefore I imagine that I need to calculate combinations independend for every single document and later add them together.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You'll need to create a new column with painless script to achieve this.

The script would work per document, but you can aggregate on the resulting column and get the stats you need.

So, you'll need to:

  • use the update_by_query API to update the existing documents with the new columns
  • Or, you could route your incomming documents through an ingest pipeline with the painless code that does this
  • Or, if you'd like to do this for existing and all incomming documents, then you'll need all of above

Note that a scripted field is not going to work, as it does not work with aggregates (last I checked)...

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!