Search code examples
solrdatastaxdatastax-enterprisedatastax-enterprise-graph

DSE: Wildcard searches


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.


Solution

  • 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*"))