Saturday 15 March 2014

ruby on rails - ElasticSearch : Combining query string with term filters -


I am using tire and elastic search in my rail project, which is a retail site for car parts I ES Power Catalog is a comprehensive search page used to browse the catalog. My question is: How do I match the filter filter to the exact query when using a query filter string, only to use an analyzer on the query string?

I hope that I will try to provide an example:

The model / index of the question is called the parts. Let's say the part has a mapping named categories and subcategories . If a user selects the brake category and the brake caliper carrier subcategory (to create a word filter), then I must ensure that the brake caliper subcategory Not even coming back ??? This is a separate subcategory, however, I want the user to be able to enter some "break" like search field ("query_string") and get results from the products in all those categories.

Here is the relevant code from the Part Model:

  def to_indexed_json fits = Fits.Tree (: map). Fit | {Make: try (: make) Trry (: name), make_id: fit.try (: make) .try (: id), model: fit.try (: model) .try (: name), model_id: Fit.try (: model) .try ( : Id), year: fit.year, sub_model: fit.sub_model} end {id: id, name: name, description: description, fitments: fits, categories: root_categories, subcategories: sub-category, price: price, status_id: Status_id, country_of_corein: country_of_corein, brand: brand, ohm: ohm, thumb_arol: part_jeas.first. Triie (: image) .tree (: thumb) .tree (: url), city: user .try (: city), inventory: inventory, part_number: part_number, user: user.try (: public_name)} .to_json and mapping Index: Name, Analyzer: 'Snowball', Boost: 40 Index: Description, Analyzer: 'Snowball', Promotion: 12 Indexed: Value, Type: "Integer" Index: Country_off_corein, Index: No_Unlisted Index: Conditions:, Type: "Integer" in Dex: brand, index :: not_anilized index: ohm, type: "boolean" index: city, index: no_national index: inventory, type: "integer" index s: part_number, index :: not_analyzed indexes: user, index :: not_analyzed indexes Type: "integer" #, index: 'not_unknown', type: index: not_analyzed indexes: indexes: make_id, type: "integer" #, index: 'not_analyzed' indexes: model index: model_id, type: Index: Year, Type: "Integer" Index: Sub-Models Index Index: Category Indexes: Name, Index :: Not Enlzed Index: ID, Type: "Integer" End Index: Sub-Categories Indexes: Name, Index: No-Unified Index: ID, Type: "Integer" End End Diff Search (Parameters = { }) Query_filters = [] tires. Search (query: page = & gt; param [: page],: per page = & gt; 20) query_filter & lt; & Lt; {: Word = & gt; {'Fitments.make_id' = & gt; Params [: making]}} if params [: making] Present? Query_filter & lt; & Lt; {: Word = & gt; {'Fitments.model_id' = & gt; Param [: model]}} Paramax [: model]. Display? Query_filter & lt; & Lt; {: Word = & gt; {'Categories.name' = & gt; Params [: Category]}} If Paramas [: Category] Present? Query_filter & lt; & Lt; {: Word = & gt; {'Sub_categories.name' = & gt; Params [: sub_category]}} If the parameter [: sub_category] Present? Query_filter & lt; & Lt; {: Word = & gt; {'City' = & gt; Param [: city]}} If the ultimate [: city]. Display? Query_filter & lt; & Lt; {: Word = & gt; {'Condition_id' = & gt; Params [: Condition]}} Paramount [: Condition]. Display? Query_filter & lt; & Lt; {: Word = & gt; {'Brand' = & gt; Params [: Brand]}} If Paramonaz [: Brand] Present? Query_filter & lt; & Lt; {: Word = & gt; {'Ohm' = & gt; Params [: oem]}} Paramonaz [: Om]. Displayed? Query querying query {if parameter [: query]. Display? String parameter [: query] and all end} filters: and, query_filters unless query_filters.empty? End And Faces ("Categories") {The word 'categories Name ', size: 50} as long as the parameter [: Category]. Display? Aspect ("city") {word 'city', size: 50} until the ultimate [: city]. Displayed? If the survey [: Category]. Displayed? & Amp; & Amp; ! Parameter [: sub_category] .present? Aspect ("sub-classes") {word 'sub-sections Name ', size: 50} end mask ("condition_id") {rule' condition_id ', size: 50} until the ultimate [: position]. Aspect ("brand") {word 'brand', size: 50} as long as the consultation [: brand]. Aspect ("om") {rule 'ohm', size: 2} until the ultimate [: ohm]. Displayed? Size parameter [: shape] If the end of the consultation [: size] end    

Elastic Use the search feature and filter on non-analyzed areas; See for example

No comments:

Post a Comment