Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to search using keyword analyzer on Elastic Search?
    primarykey
    data
    text
    <p>I have problems setting up Elastic Search with Tire and keyword type analyzer.</p> <p>My mapping definition is this:</p> <pre><code>Tire.index 'my_index' do delete create :mappings =&gt; { "my_type" =&gt; { :properties =&gt; { :id =&gt; { :type =&gt; 'string', :index =&gt; 'not_analyzed', :include_in_all =&gt; false }, :user_id =&gt; { :type =&gt; 'string', :index =&gt; 'not_analyzed'}, :team_id =&gt; { :type =&gt; 'string', :index =&gt; 'not_analyzed', :analyzer =&gt; 'keyword'}, "_timestamp" =&gt; { :enabled =&gt; true, :path =&gt; "created_on"} } } } end </code></pre> <p>I add some data with <code>team:id: "blah-blih-bloh"</code></p> <p>If I search </p> <p><code>curl -XGET 'http://localhost:9200/my_index/my_type/_search?q=team_id:blah'</code></p> <p>I can found the data I inserted, also if the analyzer was "keyword".</p> <p>I would like to user facets to group data for team_id, but given that it seems that the keyword analyzer is not working as expected, I cannot retrieve good results because it tokenizes the "team_id" field. If I have two users with team_id = "blah-blih-bloh", I would get 2 results for "blah", 2 for "blih", 2 for "bloh" and 2 for "blah-blih-bloh".</p> <p>Do I miss something?</p> <p>EDIT: I solved the problem, it was Tyre-related. Tyre was not correctly destroyng and recreating the index, if I did</p> <pre><code>curl -XDELETE </code></pre> <p>on the index of ElasticSearch, and then I executed the same code as before, mappings were created correctly, data were inserted fine and everything worked as expected.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload