custom solr indexing using analyzers from janusgraph

时间:2019-03-19 15:05:04

标签: solr janusgraph

I am trying to create index on data which has whitespaces and special charecters in solr from Janusgraph to do wild card search. to handle whitespaces and speial charecters i need to add custom analyzers for schema. so i tried as given in solr documentation.Its giving me the error as no such property parametertype.

mgmt = graph.openManagement()
string = mgmt.makePropertyKey('string').dataType(String.class).make()
text = mgmt.makePropertyKey('text').dataType(String.class).make()
mgmt.buildIndex('string', Vertex.class).addKey(string, Mapping.STRING.asParameter(),Parameter.of(ParameterType.STRING_ANALYZER.getName(),'org.apache.lucene.analysis.standard.StandardTokenizer')).buildMixedIndex("search")
mgmt.buildIndex('text', Vertex.class).addKey(text,Mapping.TEXT.asParameter(), Parameter.of(ParameterType.TEXT_ANALYZER.getName(), 'org.apache.lucene.analysis.core.WhitespaceTokenizer')).buildMixedIndex("search")
mgmt.commit()
Error: error in /tmp/Circuit_Equipment_Hierarchy_Graph_Initialization.groovy at [169: mgmt.buildIndex(Index_Prefix + G_Property, Vertex.class).addKey(G_PropertyKey, Mapping.TEXT.asParameter(), Parameter.of(ParameterType.TEXT_ANALYZER.getName(), 'org.apache.lucene.analysis.core.KeywordTokenizerFactory')).buildMixedIndex("search")] - No such property: ParameterType for class: groovysh_evaluate

I would like to try below thing as well. if any one can suggest what can be done that is really a great help.

 mgmt = graph.openManagement()
 string = mgmt.makePropertyKey('string').dataType(String.class).make()
 text = mgmt.makePropertyKey('text').dataType(String.class).make()
 mgmt.buildIndex('string', Vertex.class).addKey(string, 
 Mapping.STRING.asParameter(), Parameter.of(ParameterType.STRING_ANALYZER.getName(),'org.apache.lucene.analysis.standard.StandardTokenizer')).buildMixedIndex("search")
mgmt.buildIndex('text', Vertex.class).addKey(text, Mapping.TEXT.asParameter(), Parameter.of(ParameterType.TEXT_ANALYZER.getName(), 'org.apache.lucene.analysis.core.WhitespaceTokenizer')).buildMixedIndex("search")
  mgmt.commit()

But I need to use filters after analyzing field in solr so I have configured solr schema.xml like this

  <fieldType name="string_rev" class="solr.TextField" 
 sortMissingLast="true">
  <analyzer type="index">
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory" />
    <filter class="solr.PatternReplaceFilterFactory" pattern="[^A-Za-z0-9*]" 
replacement="" replace="all" />
    <filter class="solr.ReversedWildcardFilterFactory" />
</analyzer>
<analyzer type="query">
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory" />
    <filter class="solr.PatternReplaceFilterFactory" pattern="[^A-Za-z0-9*]" 
 replacement="" replace="all" />
</analyzer>
</fieldType>

How to configure "string_rev" wholistically in sjanusgraph so that my query is analysed by Standard tokenizer abd the filtered with patternreplace and lowercased

0 个答案:

没有答案