Stored Procedures

Can we have stored procedures in Elasticsearch as we have in MySql??
So that we can call the procedure from Java application just by its name.

What exactly do you expect these to do?

<em>to perform functions as required</em>

What functions? Please, be specific with what you want, because Elasticsearch is not MySQL.

An Example of the stored procedure would be as follows :

    CREATE PROCEDURE country_hos RETURNS char(1)
    (IN con CHAR(20))


      SELECT Name, HeadOfState FROM Country
      WHERE Continent = con;

      IF .........
    ELSE IF  ..........
    END IF

    END //

You can probably store a script using painless and do scripted fields BUT this will be super slow. It’s always better to do that at index time.

Which you can do if you wish with elasticsearch ingest script processor.

Would using these script processor affect the performance of Elasticsearch?

Indexing performance? Yes.

Search performance? No.

can we apply different functions for example aggregations ?

It’s unclear to me what is the goal of this. Can you explain the use case please?
What are the documents you have?

What is the output you need?

I have MySQL database of 11 tables. I have created stored procedure in MySQL to perform operations on the required data so that while querying i use only the proc name. Now, I want to tranfer the database to elasticsearch but still want the stored procedure in MySQL that can some how be used in elasticsearch in some manner. So these stored procedure contains some mathematical functions. I need a way to use them in elasticsearch without affecting the perfromance.

This is a technical stuff. It’s not a end user requirement.
What is the end user need?

User user need is the visual representation in terms of graphs which is been done through Java.

I’m afraid I can’t help.
May be provide an example?

I just need to know a way to use predefined functions in elastic search.

A simple addition function could also be helpful so I can relate it to find my solution.

Have you looked at aggregations?

Yes I have.

But I also need to have multiple functions with “IF,WHEN,CASE”.

So would I be able to use these clauses with aggregations??

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