Skip to content

Add Search to Aggregate pipeline #7238

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

Closed
3 tasks done
BRETT71 opened this issue Mar 3, 2021 · 8 comments
Closed
3 tasks done

Add Search to Aggregate pipeline #7238

BRETT71 opened this issue Mar 3, 2021 · 8 comments
Labels
type:feature New feature or improvement of existing feature

Comments

@BRETT71
Copy link
Contributor

BRETT71 commented Mar 3, 2021

New Feature / Enhancement Checklist

Current Limitation

Can not use the $search operator in aggregate pipelines

Feature / Enhancement Description

MongoDB Atlas has a search index for collections. You can find out more here. The way you use your search index is through aggregate. Right now if you add search to your pipeline parse throws an error.

You have to have mongo 4.2 and above and have MongoDB hosted on atlas.

Example Use Case

  1. Searching people
  2. Searching posts
    etc. (anything that you need to search)

Alternatives / Workarounds

Right now you have to use parse fulltext search which just uses a text index. You do not get fuzzy search and autocomplete

@BRETT71
Copy link
Contributor Author

BRETT71 commented Mar 3, 2021

Pull Request #7237

@dplewis
Copy link
Member

dplewis commented Mar 3, 2021

The pipeline keys haven't been updated since Mongo 3.2. I believe we can remove that check to support all stages now and future additions to mongo. What do you think?

@BRETT71
Copy link
Contributor Author

BRETT71 commented Mar 3, 2021

I like that Idea. Do you want me to update my PR to remove that check?

@dplewis
Copy link
Member

dplewis commented Mar 3, 2021

Go for it

@BRETT71
Copy link
Contributor Author

BRETT71 commented Mar 3, 2021

@dplewis Do you think that adding a search query to parse would be something useful or is doing a search through aggregate good enough?

@dplewis
Copy link
Member

dplewis commented Mar 3, 2021

We have fullText search builtin to the Server.

@BRETT71
Copy link
Contributor Author

BRETT71 commented Mar 3, 2021

Right, I understand that. I was just thinking that it would make it easier for people to use their search indexes in Parse. For example in the JS SDK the API could look like this:

const searchText = 'cool text for search 03/03/21';

const Post = Parse.Object.extend("Post");
const postQuery = new Parse.Query(Post);

const searchQuery =
{
  text: {
    path: ['body', 'title', 'postDate'],
    query: searchText,
    fuzzy: {
      maxEdits: 1, 
      prefixLength: 2, 
      maxExpansion: 100
    }
  }
};

const res = await postQuery.search(searchQuery);

// autocomplete
const searchQuery =
{
  autocomplete: {
    path: 'title',
    query: searchText,
    tokenOrder: 'any|sequential',
    fuzzy: {
      maxEdits: 1, 
      prefixLength: 2, 
      maxExpansion: 100
    }
  }
};

// true denoting that this search is a autocomplete search
const res = await postQuery.search(searchQuery, true);

I do understand if you think that this would be overkill for Parse Server.

@dplewis
Copy link
Member

dplewis commented Mar 5, 2021

closing via #7237

@dplewis dplewis closed this as completed Mar 5, 2021
@mtrezza mtrezza added type:feature New feature or improvement of existing feature and removed type:improvement labels Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or improvement of existing feature
Projects
None yet
Development

No branches or pull requests

3 participants