in reply to Re: Queries for elastic search using perl
in thread Queries for elastic search using perl

I know the module. But I am preparing the queries for the elastic search.

 ((column08=Submit & column10=Delivered & column09=Something) | (column08=Delivered))

This is the condition I am getting from GUI. I have to query the elastic search and return the result to the GUI through perl. For Quering we need to parse the condition in the form of elastic search query.

Whats my problem here is in my code (Mentioned in the main thread) 1) I am passing the inner braces to the function first

 column08=Submit & column10=Delivered & column09=Something

2) In line 58 I am giving my array to a hash

 $return_hash{'bool'}{'must'} = [@return_array];

I expected the output as

$VAR1 = ['bool' => { 'must' => [ { 'term' => { 'column08' => 'Submit' } }, { 'term' => { 'column10' => 'Delivered' } }, { 'term' => { 'column09' => 'Something' } } ] } ]

But Its returning it as

$VAR1 = [ 'bool', { 'must' => [ { 'term' => { 'column08' => 'Submit' } }, { 'term' => { 'column10' => 'Delivered' } }, { 'term' => { 'column09' => 'Something' } } ] } ];

Replies are listed 'Best First'.
Re^3: Queries for elastic search using perl
by Corion (Patriarch) on Jun 29, 2016 at 07:06 UTC

    Where do the two data structures differ?

      Near the bool. Its pushing as a element. Means the array contains two elements bool & the hash. But I expected that as a whole(one) hash.

        What do you mean exactly by "near the bool"?

        As posted, I see two data structures. The one you have:

        $VAR1 = ['bool' => { ...

        And the one you say you want:

        $VAR1 = [ 'bool', { ...

        But there is no difference to Perl between the two structures. 'bool' => ... and 'bool', ... are exactly the same. See perlop on the "fat comma".

        The fat comma is still a comma. The two structures are identical.