-
Notifications
You must be signed in to change notification settings - Fork 803
Search on attributes does not work #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Adding |
You don't have to require anything -- Bundler takes care of that. There's a full Mongoid example here: https://github.com/elasticsearch/elasticsearch-rails/blob/master/elasticsearch-model/examples/mongoid_article.rb, I advice you to try it out first. Also, be sure to generate a plain Rails app [https://github.com/elasticsearch/elasticsearch-rails/tree/master/elasticsearch-rails#usage], to get a feeling for how it works. |
Thanks for the links. I copied some from mongoid_article.rb, but I still can't search on the title attribute. > Ad.search('martin').records.first
=> #<Ad _id: 52dfccf44d61720a7c000000, title: "martin", body: nil>
> Ad.search(title:'martin').records.first
Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[_3vqU7ExR8qSv2yQ8kwhqQ][ads][4]: SearchParseException[[ads][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"multi_match\":{\"query\":{\"title\":\"martin\"},\"fields\":[\"title^10\",\"content\"]}},\"highlight\":{\"pre_tags\":[\"\\u003Cem class=\\\"label label-highlight\\\"\\u003E\"],\"post_tags\":[\"\\u003C/em\\u003E\"],\"fields\":{\"title\":{\"number_of_fragments\":0},\"content\":{\"fragment_size\":25}}}}]]]; nested: QueryParsingException[[ads] [match] query does not support [title]]; }{[_3vqU7ExR8qSv2yQ8kwhqQ][ads][0]: SearchParseException[[ads][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"multi_match\":{\"query\":{\"title\":\"martin\"},\"fields\":[\"title^10\",\"content\"]}},\"highlight\":{\"pre_tags\":[\"\\u003Cem class=\\\"label label-highlight\\\"\\u003E\"],\"post_tags\":[\"\\u003C/em\\u003E\"],\"fields\":{\"title\":{\"number_of_fragments\":0},\"content\":{\"fragment_size\":25}}}}]]]; nested: QueryParsingException[[ads] [match] query does not support [title]]; }{[_3vqU7ExR8qSv2yQ8kwhqQ][ads][1]: SearchParseException[[ads][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"multi_match\":{\"query\":{\"title\":\"martin\"},\"fields\":[\"title^10\",\"content\"]}},\"highlight\":{\"pre_tags\":[\"\\u003Cem class=\\\"label label-highlight\\\"\\u003E\"],\"post_tags\":[\"\\u003C/em\\u003E\"],\"fields\":{\"title\":{\"number_of_fragments\":0},\"content\":{\"fragment_size\":25}}}}]]]; nested: QueryParsingException[[ads] [match] query does not support [title]]; }{[_3vqU7ExR8qSv2yQ8kwhqQ][ads][2]: SearchParseException[[ads][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"multi_match\":{\"query\":{\"title\":\"martin\"},\"fields\":[\"title^10\",\"content\"]}},\"highlight\":{\"pre_tags\":[\"\\u003Cem class=\\\"label label-highlight\\\"\\u003E\"],\"post_tags\":[\"\\u003C/em\\u003E\"],\"fields\":{\"title\":{\"number_of_fragments\":0},\"content\":{\"fragment_size\":25}}}}]]]; nested: QueryParsingException[[ads] [match] query does not support [title]]; }{[_3vqU7ExR8qSv2yQ8kwhqQ][ads][3]: SearchParseException[[ads][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"multi_match\":{\"query\":{\"title\":\"martin\"},\"fields\":[\"title^10\",\"content\"]}},\"highlight\":{\"pre_tags\":[\"\\u003Cem class=\\\"label label-highlight\\\"\\u003E\"],\"post_tags\":[\"\\u003C/em\\u003E\"],\"fields\":{\"title\":{\"number_of_fragments\":0},\"content\":{\"fragment_size\":25}}}}]]]; nested: QueryParsingException[[ads] [match] query does not support [title]]; }]","status":400}
from /Users/martins/.rvm/gems/ruby-2.0.0-p353@ReTire/gems/elasticsearch-transport-0.4.7/lib/elasticsearch/transport/transport/base.rb:132:in `__raise_transport_error' |
➜ curl -XGET http://localhost:9200
{
"ok" : true,
"status" : 200,
"name" : "Vashti",
"version" : {
"number" : "0.90.9",
"build_hash" : "a968646da4b6a2d9d8bca9e51e92597fe64e8d1a",
"build_timestamp" : "2013-12-23T10:35:28Z",
"build_snapshot" : false,
"lucene_version" : "4.6"
},
"tagline" : "You Know, for Search"
} |
Would you be so kind and prepared a plain & simple application as you did in karmi/retire#915? .) |
Sure, that's what I've done. :) On Wed, Jan 22, 2014 at 3:33 PM, Karel Minarik [email protected]:
Martin Stabenfeldt |
Seems to work for me with all the stock config:
|
Ouch, this is embarrassing! 😊 Thanks for helping out again!! 👍 👍 👍 |
@stabenfeldt Cool! |
Hi again,
I updated the Rails / MongoDB proof of concept app to use elasticsearch-rails instad of ReTire. Unfortunately I still have trouble searching. Am I doing it wrong?
models/ad.rb
The text was updated successfully, but these errors were encountered: