pgj commented on code in PR #4810:
URL: https://github.com/apache/couchdb/pull/4810#discussion_r1372064169


##########
src/mango/src/mango_selector_text.erl:
##########
@@ -142,6 +142,10 @@ convert(Path, {[{<<"$exists">>, ShouldExist}]}) ->
         true -> FieldExists;
         false -> {op_not, {FieldExists, false}}
     end;
+convert(Path, {[{<<"$beginsWith">>, Arg}]}) when is_binary(Arg) ->
+    Suffix = <<"*">>,
+    PrefixSearch = value_str(<<Arg/binary, Suffix/binary>>),
+    {op_field, {make_field(Path, Arg), PrefixSearch}};

Review Comment:
   It is almost there.  The problem with this version is that it will quote the 
`*` (wildcard) therefore neutralize that.  Here is an alternative that fixed 
`03-operator-test.OperatorTextTests.test_beginswith` for me:
   
   ```erlang
   convert(Path, {[{<<"$beginsWith">>, Arg}]}) when is_binary(Arg) ->
       Prefix = mango_util:lucene_escape_query_value(Arg),
       Suffix = <<"*">>,
       PrefixSearch = <<Prefix/binary, Suffix/binary>>,
       {op_field, {make_field(Path, Arg), PrefixSearch}};
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to