Search / Filter for Records not working as expected

DatoCMS Record Search not yielding proper results

  • Not sure if I am doing something wrong or if the record search / filtering is a bit strange in datoCMS
  • Here is how you can reproduce the issue:
  1. Create a record called DCO2-314
  2. Duplicate the record and call it DCO2-314a
  3. Duplicate the record again and call it DCO2-314b
  4. Search the records by DCO2-314 (Note: no “filters” are active)
  5. I would assume all three items show up, but only the exact match shows up. Searching for DCO2-314b does not show the exact match at all.
  • Again: Happy to learn that I am doing something wrong or this is the intended behavior but it seems odd to me.

Hello @joerg.egli, and welcome to the forum!

Which project and model is this in? Could you please provide a URL (you can DM me if you wish) so I can take a look at this inside your actual project?

Here is the link to the project and the model where you can see the behavior:

https://visitorguide.admin.datocms.com/environments/stage/editor/item_types/909824/items

EDIT: and thanks for looking into this so quickly @roger :slight_smile: much appreciated.

Got it, thank you!

I think you are running into a couple of annoying little issues here (not your fault, just quirks of the search system):

First, it might take a few min for the search index to update. If you wait a little bit, 314b should show up eventually:

So that’s one issue… just give it a sec and it should work eventually.


Separate from that, though, I think the reason you don’t see the 314a and 314b records when you search for DCO2-314:

is probably due to the “stemming” we have to do on the main search box, which is searching across all the record’s fields (not just its title) and typically works better with organic natural words rather than technical product IDs. In this case, it’s probably the hyphen confusing the stemmer algorithm. It’s not a simple wildcard search across all fields.

For this particular use case, rather than using the primary search box (that tries to be a bit too “smart” sometimes), I think it would be better for you to use the explicit filters to search only by that field via the “contains” operator:

You can also save that as a template in the saved filters so you can easily pull it back up and modify the ID as necessary.

This will bypass the search system’s guesswork and stemming and just get you the exact substring matches that you want for this use case.

Would that work?

Or in German: