Es5.0 + drupal 7


(Denis) #1

Hi All.
I have the task of integrating drupal 7 and elasticssearch 5.0. Drupal module which should solve this problem now in DEV and has many bugs. I can't fix last of them.
When i send this query

   {  
      "index":"...",
      "type":"...",
      "body":{  
         "from":0,
         "size":"24",
         "query":{  
            "bool":{  
              "must":{  
                  "match_all":{  
                  }
               },
               "filter":{  
                  "geo_distance":{  
                     "distance":"48.28km",
                     "field_geo_location:latlon":{  
                        "lat":41.845183,
                        "lon":-74.082085
                     }
                  },
                     "term":{  
                        "status":1
                     }
               },

               "must_not":[  
                  {  
                     "term":{  
                        "type":"type 1"
                     }
                  },
                  {  
                     "term":{  
                        "type":"type 2"
                     }
                  },
                  {  
                     "term":{  
                        "type":"type 3"
                     }
                  },
                  {  
                     "term":{  
                        "type":"type 4"
                     }
                  },
                  {  
                     "term":{  
                        "nid":"6452"
                     }
                  }
               ],
               "should":[  
                  {  
                     "term":{  
                        "status":1
                     }
                  },
                  {  
                     "term":{  
                        "author":"3686"
                     }
                  },
                  {  
                     "term":{  
                        "search_api_access_node":"node_access_all:0"
                     }
                  },
                  {  
                     "term":{  
                        "search_api_access_node":"node_access_nodeaccess_userreference:3686"
                     }
                  },
                  {  
                     "term":{  
                        "search_api_access_node":"node_access_nodeaccess_userreference_author:3686"
                     }
                  },
                  {  
                     "term":{  
                        "search_api_access_node":"node_access_nodeaccess_userreference_all:1"
                     }
                  },
                  {  
                     "term":{  
                        "search_api_access_node":"node_access__all"
                     }
                  }
               ]
            }
         },
         "aggs":{  
         	[here some aggs]
         }
      }
   }            

I see next error message
"[geo_distance] malformed query, expected [END_OBJECT] but found [FIELD_NAME]"
Can someone say what the problem is


(Abdon Pijpelink) #2

You're providing two filter clauses: a geo_distance and a term query. So you need to pass in an array to the bool query's filter clause using square brackets:

"filter": [
        {
          "geo_distance": {
            "distance": "48.28km",
            "field_geo_location:latlon": {
              "lat": 41.845183,
              "lon": -74.082085
            }
          }
        },
        {
          "term": {
            "status": 1
          }
        }
]

(Denis) #3

Thanks


(Denis) #4

Once more and i hope final problem with this ES task

{  
   "from":0,
   "size":"24",
   "query":{  
      "bool":{  
         "filter":[  
            {  
               "term":{  
                  "status":"1"
               }
            },
            {  
               "geo_distance":{  
                  "distance":"48.28km",
                  "field_geo_location:latlon":{  
                     "lat":41.845183,
                     "lon":-74.082085
                  }
               }
            }
         ],
         "must_not":[  
            {  
               "term":{  
                  "nid":"6452"
               }
            }
         ],
         "should":[  
            {  
               "term":{  
                  "type":"type 1"
               }
            },
            {  
               "term":{  
                  "type":"type 2"
               }
            },
            {  
               "term":{  
                  "type":"type 3"
               }
            },
            {  
               "term":{  
                  "type":"type 4"
               }
            }
         ]
      }
   },
   "aggs":{ 
   [some aggs] 
   }
}

This query returns no error but it's looks like [must_not] and [should] sections ignored.
How they should looks like?


(system) #5

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