-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DOCSP-35959: search text #2889
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
DOCSP-35959: search text #2889
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. A couple suggestions and one issue, but I think it can be resolved without another review. Feel free to reach out if you want me to take another look!
Search Text Fields | ||
------------------ | ||
|
||
You can perform a text search by using the :manual:`$text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
I think it could be better to swap this paragraph (describes how to perform one) with the one following it (describes what a text search is). The first paragraph also seems more connected to the third paragraph ("After building your query...").
This example calls the ``where()`` method on the ``Movie`` Eloquent model to | ||
retrieve documents in which the ``plot`` field contains the phrase | ||
``"love story"``: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue:
I think the creation of the index needs to be mentioned or shown to understand that "plot" is the indexed field.
Suggestion:
I think either mentioning that the text index was created on the "plot" field or showing an example of creating the index similar to this Java documentation would help a reader understand the connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned this in the note, but I can also add a sentence that explains that the example assumes a text index on the plot
field
.. note:: | ||
|
||
To specify a phrase as the text search criteria, you must include it | ||
with escaped quotes in the query filter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question:
Perhaps a question for the technical reviewer, but is it possible to use single quotes instead of double quotes to represent the value of the $search key (which would hopefully avoid having to escape the quotes and concatenate strings)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use single quote everywhere, unless I want to use variable injection with double quotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested this improvement and it works! removing the admonition
{ | ||
public function show() | ||
{ | ||
$movies = Movie::where('$text', ['$search' => "\"" . 'love story' . "\""]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure it's better like this. The doubles quotes will probably come from user input.
$movies = Movie::where('$text', ['$search' => "\"" . 'love story' . "\""]) | |
$movies = Movie::where('$text', ['$search' => '"love story"']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this improvement! Was struggling to make this work, didnt realize the solution was so simple.
461bef2
to
802f50e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I updated the test and examples.
…-mongodb into DOCSP-35959-search-text
JIRA
STAGING
docs PR
Checklist