1

I am currently attempting to do a wildcard search and edited my schema file accordingly using the link here, I have also read up the following thread and attempted to do the necessary changes for SOLR and queried using token(hel*o) but failed to accomplish the desired search results. Hence, I would like to ask if my approach for wildcard searches is incorrect? As I noticed that regular expressions can be searched using tokenRegex(...) without the need of changing the schema.

===Update===

DSE Version : 6.7.2
Execution code : g.V().hasLabel("person_node").has("name", "Jo*")

Schema Used
----------------
<fieldType class="org.apache.solr.schema.TextField" name="TextWildcard">
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.ReversedWildcardFilterFactory" withOriginal="true" maxPosAsterisk="3" maxPosQuestion="2" maxFractionAsterisk="0.33"/>
    <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>

I would like to achieve a normal wildcard query where * means that there can be many matches of non-space characters e.g Hel*o will be able to match Hello, Heleawo or Helzzzzo.

Additionally, it will also work with ? where it matches only one non-space character e.g Hel?o will match Helzo and not Helzzzo.

Alex Ott
  • 80,552
  • 8
  • 87
  • 132
WhiteSolstice
  • 641
  • 2
  • 7
  • 20
  • What DSE version is used, and how do you execute queries. What is the schema that you created, and most important - what do you want to achieve - something like SQL's 'LIKE' operation? – Alex Ott May 08 '19 at 06:53
  • @AlexOtt I have updated the post and I hope it answers your request. – WhiteSolstice May 08 '19 at 08:09

1 Answers1

1

Ah, ok - you're not using correct graph operation. To perform what you want you need following:

Create search index on given property with:

schema.vertexLabel('person_node').index('searchname').search().by('name').asString().add()

Perform search with:

g.V().hasLabel("person_node").has("name", regex("Jo*"))
Alex Ott
  • 80,552
  • 8
  • 87
  • 132
  • I have attempted the solution presented but it is still analyzing it in terms of regular expressions where `Jo*` will match `Jooooooooo` and not `John`, if I want to resolve this there will be a need to do `Jo.*` where `.` represents any character. @Alex Ott – WhiteSolstice May 09 '19 at 01:32
  • 1
    Every system uses has it's own regex language. Here the Java's is used... – Alex Ott May 09 '19 at 06:48