Skip to content

Creating custom analyzer in CreateSearchView by defining the analyzer in driver.ArangoSearchElementProperties #392

@aaqibb13

Description

@aaqibb13
viewName, err := db.CreateArangoSearchView(ctx, myViewName, &driver.ArangoSearchViewProperties{
Links: driver.ArangoSearchLinks{
	collectionName: driver.ArangoSearchElementProperties{
		AnalyzerDefinitions: []driver.ArangoSearchAnalyzerDefinition{
			{
				Name: "custom_analyzer",
				Type: driver.ArangoSearchAnalyzerTypePipeline,
				Properties: driver.ArangoSearchAnalyzerProperties{
					Locale: "en_US.utf-8",
					Pipeline: []driver.ArangoSearchAnalyzerPipeline{
						{
							Type: driver.ArangoSearchAnalyzerTypeNorm,
							Properties: driver.ArangoSearchAnalyzerProperties{
								Locale: "en_US.utf-8",
							},
						},
						{
							Type: driver.ArangoSearchAnalyzerTypeNGram,
							Properties: driver.ArangoSearchAnalyzerProperties{
								Min:              utils.NewInt64(1),
								Max:              utils.NewInt64(14),
								PreserveOriginal: utils.NewBool(false),
							},
						},
					},
				},
			},
		},
		Fields: map[string]driver.ArangoSearchElementProperties{
			"businessName": {
				Analyzers: []string{
					"text_en",
				},
			},
			"locationName": {
				Analyzers: []string{
					"text_en",
				},
			},
		},
	},
},
	})
	if err != nil {
		log.Println("error creating view: ", err)
	}
  • Do I need to add my custom_analyzer in Fields like:
Fields: map[string]driver.ArangoSearchElementProperties{
			"businessName": {
				Analyzers: []string{
					"text_en",
                                       "custom_analyzer",
				},
			},
			"locationName": {
				Analyzers: []string{
					"text_en",
                                       "custom_analyzer",
				},
			},
		},

or the underlying analyzer that I'm using, like norm and ngram for instance.

  • What I want to achieve is to create a pipeline type analyzer with underlying norm and ngram analyzers. What I'm trying to achieve is this:
analyzers.save(
  'bigram', 
  'pipeline', 
  { 
    pipeline: [ 
      { type:'norm',  properties: { locale:'en', case:'lower'} }, 
      { type:'ngram', properties: { min:2, max:2, preserveOriginal: false, streamType:'utf8' } }
    ]
  }, 
  ["frequency","norm","position"]);

As a side note: I did look at #318 and tried to find a work around database_arangosearch_analyzers_impl.go. I'd love any help in this regard.
@maierlars to the rescue, maybe? ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions