0

I have a large volume of file names which include periods in them. This seems to join them to one large word and stops them being picked up using TextCriteria searching.

For example /example/test.one.two.three.txt If I search two it doesn't seem to be picked up, however if I have /example/test one two three.txt searching two will return the file.

Am I able to set the separator for the query on the .? Alternatively I can split the words when saving into Mongo but that seems messy. At the moment I'm using a very simply TextCriteria:

TextCriteria textCriteria = new TextCriteria();
textCriteria.matchingAny(query);

Any tips?

Chris
  • 3,437
  • 6
  • 40
  • 73
  • You're jumping to the wrong conclusion for a solution here. You don't want `$text` for this type of query. You want regular expressions ( or `$regex` ) to match the particular types of "terms" here which would be otherwise excluded as "stopwords". Note that you can "still" take advantage of case insensitive collation on an index even with regular expressions, as long as you also select the `"i"` option. – Neil Lunn Nov 12 '18 at 04:51
  • Thanks for the comment, I don't believe this is a duplicate as I'm not asking about case sensitivity. Thanks though for the regex tip, I'll google and see what I can find. – Chris Nov 12 '18 at 04:55
  • Well I think it "is a duplicate". The intent is quite clear in `textCriteria.caseSensitive(false);`, so I suggest you read the other solutions or at least show "why" these would not apply. `$text` searches do **NOT** match "words" like "and" or "not" etc, which basically seems the essence of what you are looking to match. – Neil Lunn Nov 12 '18 at 04:59
  • You're focusing way to much on that one aspect of my query. I want to know how I can successfully find a string of `test.one.two.three` when I can successfully find `test one two three` regardless of case. More importantly that very link you provided strongly recommends **NOT** to use regex. – Chris Nov 12 '18 at 05:02
  • Dude. Show us why the linked duplicates don't actually apply to your unique question then. I say everything there has a direct application and you simply are not looking at it. A regular expression will solve this, so if you think it does not then **show us exactly why it does not work**. Otherwise "duplicate". – Neil Lunn Nov 12 '18 at 05:05

0 Answers0