When to use "file-based scripts" in elasticsearch?


(Elham Roshan) #1

Hi,

I need to check if fieldX exists in each document in the Index. Then for those which it doesn't, I would like to get the value of fieldY of the same document, run a python function on that field and store the result in the fieldX.

doc1.fieldX = doesn't exist
doc1.fieldY = "This is a text that a python function will analyse it"

pythonFunction(doc1.fieldY) = ["text","python","function"]

In the end, after the update, I should have something like:

doc1.fieldX = ["text","python","function"]
doc1.fieldY = "This is a text that a python function will analyse it"

I just learnt about "file-based scripts" concept in elasticsearch. Wondering if it's better that I use this concept and update the data or I'd better handle everything from Python(connect to db, read data, get the value of each fieldY, update fieldX accordingly)?

Thanks,
Ellie


(Alexander Reelsen) #2

file based scripts have been removed. Also, you cannot run python code within Elasticsearch. So you might want to search for documents missing a certain field (by negating the exists query) and then use the update API. Or you can check if the requirement you need to do can be done within painless, the scripting language used within Elasticsearch - which might not be the case if you do something like NLP processing.

Hope this helps!


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.