Correcting indexes

Hello. I’m new to Mongo but have inherited a product DB that I need to correct indexes on so that searches behave as expected with case insensitivity, fuzzy, etc. I want to get as many gains as I can via indexes prior to cracking open the frontend code. Note- collation options were not set during the creation of the collection being queried. While I’ve watched and read a lot about MongoDB indexes, I seem to be having different than expected experiences. The Search Tester in the UI returns case-insensitive results but queries on the same term via Compass and the Shell are only returning exact matches. Please advise if this is normal behavior and the best method for creating/modifying indexes. The different connection methods seem to have different granularity but none seem to solve the case issue. Nor does adjusting analyzers settings. A pointer to a good explanation of the differences and relationships between the DB indexes and Search Indexes would also be appreciated. Thanks!

Hi @Michael_Davis ,

If I understand correctly you are working with Atlas and Atlas search for the application right?

If so there are verious ways to make a query of you choice including fuzzy/case sensitive r I sensitive or etc as long as they used with $search aggregation and appropriate search index. The search tester by default uses a simple text $search stage…

In compass regular queries are not using Atlas search by default as long as you don’t explicitly use $search in aggregation pipeline builder or shell…

I would recommend reading through some of our articles and checking out our search demo site:

Thanks

Hi Pavel. I’ve read a bunch of the docs and watched that video. I’m excited to build something similar. Before I do- I need to understand how to best apply indexes via command or UI to achieve the base settings. I also must understand how to query via Shell and preferably Compass to include the Search indexes to verify index performance and results. It feels like a stupid question but I’m not finding the right doc or training describing these items.

Hi @Michael_Davis ,

Ok I will try to help you.

Can you provide sample documents and desired results /query results and what query have you tried so far?

Thanks

Hi Pavel. Any chance for a 10-minute call? I think that would get me over the hump.

Pavel- The forum will not allow me as a new user to upload docs. Here’s a link for the requested items. Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.
Thank you!

Hi @Michael_Davis ,

I am not sure I fully understand the current problem. Atlas search indexes by default apply stemming of words like “of” , “the” and etc…

The provided documents and configuration seems to be configured only on 2 fields in the slugPublishedTags collection : "tagCategory", "tagText"


  tagCategory: 'Text',
  tagText: 'leadership' 

Now those fileds hold only one word which is not ideal for full text searching, why the example is made that way, is that the usecase?

Please note that in order to use fuzzy, you need to specify the “fuzzy” keyword in your search aggregation input, for me making mistakes like ladership found the document.

Also doing upper case search found lower case data so that works as case insensitive

Stemming words also work:

Now for synonyms you might have a few problems here:

  1. Your synonyms collection defenition on the text index is specified with lucene.standard analyser while one of the fields is with English analyser and those won’t be compatible for any field search.
  2. Synonym searches cannot be done together with fuzzy logic. So you will have to run seperate queries for them…

Here is my synonym for testing : “captin” => “leadrship” :

{ _id: ObjectId("624e9fd51384330cb92a56c7"),
  mappingType: 'explicit',
  input: [ 'captin' ],
  synonyms: [ 'leadership' ] }

It works perfectly when I switched to english analyser for synonyms :

For all the examples above I’ve used the compass aggregation tab with a $search stage :slight_smile:

Hope that helps

Pavel

Hello. I’m new to Mongo but have inherited a product DB that I need to correct indexes on so that searches behave as cps counter expected with case …The Concentration Index enjoys an increasing popularity as an indicator of the inequality of health in relation to the socioeconomic position of individuals.

@Nora_davis ,

I suggest to open a separate topic for a different question…

Thanks
Pavel