elasticsearch - Elastica - How to add a filter - object term -


How to do my custom query with Alstica I have a search form to search for products, where the user can enter the name Can choose a category, a brand etc.

My product mapping has a field called "category_id" in which you can guess as an ID category and there is another area called "category" in which there is an object.

When I display all the products without filters, then this is an example of the field:

  [category] = & gt; Array ([id] = & gt; 2 [name] = & gt; laptop [slug] => laptop [created_ta] => 2012-03-12T17: 11: 42 + 0000 [updated_at] = & gt; ; 2013-04-25T00: 01: 04 + 0000)  

I manually added the previous "category_id" field but I did not know the "category" field. To avoid overloading your product mapping, I want to know how to create a query by specifying the ID of the "Category" field.

How do I actually do this:

$ elasticaFilterCategory = new \ Elastica \ Filter \ term (); $ IListikaFilter Category- & gt; Setarm ('category_id', $ category_id]);

I checked the doctor of Elastica and we can accept the array setTerm ():

So I tried without success:

  $ elasticaFilterCategory = new \ Elastica \ Filter \ Term (); $ ElasticaFilterCategory-> Settrum ('category', array ("id" => gt; $_id_id_id_id_id);)  

You can use something like this

  $ ElasticaFilterCategory = New \ Elastica \ Filter \ Term (); $ IListikaFilter Category- & gt; Setarm ('category.id', $ category_id);  

Comments