Elasticsearch Server Second Edition by Unknown

Elasticsearch Server Second Edition by Unknown

Author:Unknown
Language: eng
Format: mobi
Publisher: Packt Publishing


As you can see, we used JavaScript for scripting instead of the default MVEL. The lang parameter informs Elasticsearch about the language being used.

Using our own script library

Usually, scripts are small and it is quite convenient to put them in the request. But sometimes applications grow and you want to give the developers something that they can reuse in their modules. If the scripts are large and complicated, it is generally better to place them in files and only refer them in API requests. The first thing to do is to place our script in the proper place with a proper name. Our tiny script should be placed in the Elasticsearch directory, config/scripts. Let's name our example script file text_sort.js. Note that the extension of the file should indicate the language used for scripting; in our case, we will use JavaScript.

The content of this example file is very simple and looks as follows:

doc.tags.values.length > 0 ? doc.tags.values[0] :'ᦙ9';



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.