Code Monkey home page Code Monkey logo

Comments (3)

leschenko avatar leschenko commented on July 30, 2024

Hi, sorry for delay - I was too busy with my job.

Query with Martin I get all results with Martín, martín, martin, Martin

this is because elasticsearch_autocomplete use asciifolding filter http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-asciifolding-tokenfilter.html
I think you should define your custom analyzers for your case

elasticsearch recently released suggester for autocomplete, may be you will find this internal solution better http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html

I'm using mongoid instead active record.

doesn't metter

from elasticsearch_autocomplete.

hyperrjas avatar hyperrjas commented on July 30, 2024

I have the same problem with completion suggester. I have tried in many ways. I have checked with this way:

Model user:

class User
  include Mongoid::Document
  field :city, :type => String
  has_one: car
end

Model car:

class Car
  include Mongoid::Document
  ac_field :name, :user_city, :skip_settings => true

  belongs_to: user
  field: :name, :type => String

  def ac_self.search(param)
    tire.ac_search :load => true do
    query do
      boolean do
        must { term :user_city, params[:user_city] } if params[:user_city].present?
      end
    end
    filter :term, user_city: params[:user_city] if params[:user_city].present?
    facet "cities" do
      terms :user_city
    end
  end

  def to_indexed_json
    to_json(methods: [:user_city])
  end

  def user_city
   user.city
  end

end

This is my filter with facet user_city

 <% @cars.facets['cities']['terms'].each do |facet| %>
  <li>
    <%= link_to_unless_current Car.find_or_initialize_by(city: facet['term']).city, params.merge(user_city: facet['term']) %>
    <% if params[:car_city] == facet['term'].to_s %>
     (<%= link_to "Remove", params.merge(car_city: nil) %>)
    <% else %>
      (<%= facet['count'] %>)
    <% end %>
  </li>
<% end %>

Once I'd made a search, I'd like to filter by the city of the vehicle owner.

If I add my own mapping, asciifolding filter doesn't works. This is the main problem. How can I use asciifolding filter with my own mapping.

Thanks!

from elasticsearch_autocomplete.

hyperrjas avatar hyperrjas commented on July 30, 2024

Ok I fixed the error with:

model = self
  settings ElasticsearchAutocomplete::Analyzers::AC_BASE do
    mapping _source: {enabled: true, includes: %w(car_city name)} do
      indexes :car_city, :type => 'string', :index => :not_analyzed 
    end
  end

Thanks!

from elasticsearch_autocomplete.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.