Stored Procedures

(Teddy) #1

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.

(Mark Walkom) #2

What exactly do you expect these to do?

(Teddy) #3


to perform functions as required


(Mark Walkom) #4

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

(Teddy) #5

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 //

(David Pilato) #6

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.

(Teddy) #7
Would using these script processor affect the performance of Elasticsearch?

(David Pilato) #8

Indexing performance? Yes.
Search performance? No.

(Teddy) #9

can we apply different functions for example aggregations ?

(David Pilato) #10

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?

(Teddy) #11

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.

(David Pilato) #12

This is a technical stuff. It's not a end user requirement.

What is the end user need?

(Teddy) #13

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

(David Pilato) #14

I'm afraid I can't help.

May be provide an example?

(Teddy) #15

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.

(Mark Walkom) #16

Have you looked at aggregations?

(Teddy) #17

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??

(system) #18

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