-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
How to use Mongodb v3 index search in Parse Server? #6781
Comments
In the docs you can find examples: // Sorts the results in ascending order by the score field
query.ascending("score");
// Sorts the results in descending order by the score field
query.descending("score"); MongoDB will automatically choose an appropriate index. You can find more infos regarding indexing in the docs. |
I already implemented this but this searching on only one column , I want to apply search on all columns like firstname, lastname and description and want to order by firstname. I have achieved this by OR query but this query taking long execution time on my 175K records. ANy solution? |
let query = new Parse.Query("_User");
query.equalTo("firstname", "John");
query.equalTo("lastname", "Doe");
query.equalTo("description", "example");
query.descending("firstname"); If this is not what you mean, please provide an example data set, your current code, the current multikey index, the expected results and the actual results. You may find it helpful to use the issue template for better overview. |
I don't want an exact match of firstname and lastname
I have a class "Artists". In this class I have few fields (firstname,
lastname, description).
Now I want to search Artist based on the string,
Example: User type `paint` ina front end form, this will be search in
firstname, lastname and description to see if any entry have "paint" in any
of the three column and want to order on a firstname.
…On Thu, Jul 9, 2020 at 10:26 AM Manuel ***@***.***> wrote:
I want to apply search on all columns like firstname, lastname and
description and want to order by firstname.
let query = new Parse.Query("_User");query.equalTo("firstname", "John");query.equalTo("lastname", "Doe");query.descending("firstname");
If this is not what you mean, please provide an example data set, your
current code, the expected results and the actual results.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6781 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH2FCRGEAVDLLESKNKLXJG3R2VEYHANCNFSM4OUXNWJQ>
.
|
You would have to create a text index manually in the DB: db.Artists.createIndex({
firstname: "text",
lastname: "text",
description: "text"
}) Then do a text search as described in the docs: let query = new Parse.Query("Artists");
query.fullText("firstname", "paint");
query.ascending("firstname");
let results = await query.find(); If a text index is a compound index, then the search will automatically cover all fields of the text index. This is expected behavior by MongoDB but not explicitly mentioned in the Parse Server docs. It makes sense to add this to the docs, a PR would be very welcome. |
Yes I have the custom index, so I just need to write a fulltext query with
the first key (firstname) in the compound index, right?
…On Thu, Jul 9, 2020 at 8:11 PM Manuel ***@***.***> wrote:
You would have to create the index manually in the DB:
db.Artists.createIndex({
firstname: "text",
lastname: "text",
description: "text"})
Then do a text search as described in the docs
<https://docs.parseplatform.org/js/guide/#queries-on-string-values>:
let query = new Parse.Query("Artists");query.fullText("firstname", "paint");query.ascending("firstname");let results = await query.find();
If a text index is a compound index, then the search will automatically
cover all fields of the text index. This is expected behavior by MongoDB
but not explicitly mentioned in the Parse Server docs.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6781 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH2FCRD3CBCTFNM7PPITLXLR2XJKTANCNFSM4OUXNWJQ>
.
|
I have applied this but the search does not returning all the match result in a sorting (firstname ascending) and also lot of search saying no records but we have an search string in the |
You can try to execute the query directly against MongoDB without using Parse and see if you get the expected results. If you also don't get the expected results from a direct query, then you may look at the data and index and maybe consult the MongoDB docs on how to get your expected results. If you get the correct results from MongoDB but not from Parse, then we need to look at the details:
|
It seems to be working, I think indexing was under processing.. |
Great, would you want to create a PR for the docs and add an example for compound text index? That could certainly help others. |
Yes, that would be a great to have an detailed documentation, MongoDb have an well described documentation but this is missing in the Parse. |
Do you want to add it to the docs? |
Yes |
Please also post the link of documentation in this ticket, so user who read this issue can find documentation directly. |
You can link to the documentation after you have added it. Just to be clear, I was asking if you want to submit a pull request the change to the documentation yourself. |
You mean I need to write a document for this? If yes then where? |
Yes, that would be very helpful. 🙂 It is quite easy, you can find some guides online how to make a pull request. For example this guide if you use Github Desktop. Let me know if you need any help and I will guide you. |
Thanks for the info, I will create doc for this and push to the repo. |
Let me know if you need any help with how to contribute and open a PR 🙂 |
I'm closing this as it seems to be resolved. Feel free to comment if you have any questions and we can re-open this issue. Docs issue in parse-community/docs#750 |
Hi All,
I am using Parse Server with Mlab. I have created a
Multikey index
from mlab dashboard. Now I wan to use search inCloud Function
ofParse Server
, but I didn't found any option in Parse Server to run Query and order by on a specific field.Anyone have idea how we can perform Search and other MOngo V3 queries in parse server?
Thanks
The text was updated successfully, but these errors were encountered: