Skip to content
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

ParserMethods.parse_query - Why sub! and not gsub! parsing filter queries #8

Open
homerlex opened this issue Jun 4, 2010 · 1 comment

Comments

@homerlex
Copy link

homerlex commented Jun 4, 2010

In this line of ParserMethods.parse_query:

query_options[:filter_queries] = replace_types([*options[:facets][:browse]].collect{|k| "#{k.sub!(/ *: */,"_facet:")}"}) if options[:facets][:browse]

Why is it k.sub! and not k.gsub! ? Wouldn't we want to replace ALL occurrences of the property names in the string?

If I have an fq of "(property_x:1 OR property_y:1)" then the above code will result in:

"(property_x_facet:1 OR property_y:1)"

What I really want in the end is:

"(property_x_facet:1 OR property_y_facet:1)"

Same question about the line that parses [:facets][:queries]:
query_options[:facets][:queries] = replace_types(options[:facets][:query].collect{|k| "#{k.gsub!(/ *: */,"_t:")}"}) if options[:facets][:query]

@dcrec1
Copy link
Owner

dcrec1 commented Jun 5, 2010

You're right, in the case you have options[:facets][:query] = ["property_x:1 OR property_y:1"], the query will break.

Can you create a test case and submit a patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants