Anonymous avatar Anonymous committed f56a820

Honor the solr q.op param

Comments (0)

Files changed (4)

apps/riak_search/include/riak_search.hrl

           parent=undefined,
           index=undefined,
           field=undefined,
+          default_op,
           num_terms=0,
           num_docs=0,
           query_norm=0,

apps/riak_search/src/riak_search_client.erl

     {ok, Schema} = riak_search_config:get_schema(IndexOrSchema),
     DefaultIndex = Schema:name(),
     DefaultField = Schema:default_field(),
+    DefaultOp = Schema:default_op(),
     {ok, Ops} = lucene_parser:parse(
                   riak_search_utils:to_list(DefaultIndex),
                   riak_search_utils:to_list(DefaultField),
                   riak_search_utils:to_list(Query)),
-    {ok, riak_search_op:preplan(Ops)}.
+    {ok, riak_search_op:preplan(Ops, #search_state{default_op=DefaultOp})}.
 
 
 

apps/riak_search/src/riak_search_op_group.erl

             %% appropriately.
             Index = State#search_state.index,
             {ok, Schema} = riak_search_config:get_schema(Index),
-            case Schema:default_op() of
+            DefaultOp =
+                case State#search_state.default_op of
+                    undefined ->
+                        Schema:default_op();
+                    Else ->
+                        Else
+                end,
+            case DefaultOp of
                 'and' ->
                     NewOp = #intersection { id=Op#group.id, ops=OpList };
                 'or' ->

apps/riak_solr/src/riak_solr_searcher_wm.erl

             {error, missing_query};
         false ->
             DefaultField = wrq:get_qs_value("df", undefined, Req),
-            DefaultOp = to_atom(wrq:get_qs_value("q.op", undefined, Req)),
+            DefaultOp = case wrq:get_qs_value("q.op", undefined, Req) of
+                            undefined ->
+                                undefined;
+                            Other ->
+                                to_atom(string:to_lower(Other))
+                        end,
             QueryStart = to_integer(wrq:get_qs_value("start", 0, Req)),
             QueryRows = to_integer(wrq:get_qs_value("rows", ?DEFAULT_RESULT_SIZE, Req)),
             SQuery = #squery{q=Query,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.