What is the basic logic behind the DSL query pattern?


(_chetansharma) #1

I am working on a project which is going to use the elasticsearch very
intensively in future, but i have trouble in implementing the DSL queries
as I am new to both ElasticSearch and Lucene.

I am using PHP

here is example of my code:

$options['query'] = array(
'query' => array(
'filtered' => array(
'query' => array(
'query_string' => array(
'default_field' => 'name',
'query' => $this->search_term . '*',
),
),
'filter' => array(
'and' => array(
array(
'term' => array(
'access_id' => 2,
),
),
),

                'not' => array( 
                    array( 
                        'term' => array( 
                            'follower' => 32, 
                        ), 
                    ), 

                    array( 
                        'term' => array( 
                            'fan' => 36, 
                        ), 
                    ), 
                ), 
            ), 
        ), 
    ), 
); 

as this query is meant to search the user with access_id = 2, but must not
have the follower of id 32 and fan of id 36

but this is not working..

Please help thanks.


(_chetansharma) #2

'filter' => array(
'and' => array(
array(
'term' => array(
'access_id' => 2,
),
),
array(
'not' => array(
'term' => array(
'follower_of_inverse' => 32,
),
),
),
),
),

I have changed the query as follow and it works a little,
but how do i add the second filter in it.

Waiting for response..


(Clinton Gormley) #3

Hi Chetan

I have changed the query as follow and it works a little,
but how do i add the second filter in it.

Waiting for response..

I have answered your question on stackoverflow:

clint


(system) #4