Exemple #1
0
func printRegistry() {
	types, instances := registry.CharFilterTypesAndInstances()
	printType("Char Filter", types, instances)

	types, instances = registry.TokenizerTypesAndInstances()
	printType("Tokenizer", types, instances)

	types, instances = registry.TokenMapTypesAndInstances()
	printType("Token Map", types, instances)

	types, instances = registry.TokenFilterTypesAndInstances()
	printType("Token Filter", types, instances)

	types, instances = registry.AnalyzerTypesAndInstances()
	printType("Analyzer", types, instances)

	types, instances = registry.DateTimeParserTypesAndInstances()
	printType("Date Time Parser", types, instances)

	types, instances = registry.KVStoreTypesAndInstances()
	printType("KV Store", types, instances)

	types, instances = registry.ByteArrayConverterTypesAndInstances()
	printType("ByteArrayConverter", types, instances)

	types, instances = registry.FragmentFormatterTypesAndInstances()
	printType("Fragment Formatter", types, instances)

	types, instances = registry.FragmenterTypesAndInstances()
	printType("Fragmenter", types, instances)

	types, instances = registry.HighlighterTypesAndInstances()
	printType("Highlighter", types, instances)
}
Exemple #2
0
func BleveMetaExtra(m map[string]interface{}) {
	br := make(map[string]map[string][]string)

	t, i := bleveRegistry.AnalyzerTypesAndInstances()
	br["Analyzer"] = map[string][]string{"types": t, "instances": i}
	t, i = bleveRegistry.ByteArrayConverterTypesAndInstances()
	br["ByteArrayConverter"] = map[string][]string{"types": t, "instances": i}
	t, i = bleveRegistry.CharFilterTypesAndInstances()
	br["CharFilter"] = map[string][]string{"types": t, "instances": i}
	t, i = bleveRegistry.DateTimeParserTypesAndInstances()
	br["DateTimeParser"] = map[string][]string{"types": t, "instances": i}
	t, i = bleveRegistry.FragmentFormatterTypesAndInstances()
	br["FragmentFormatter"] = map[string][]string{"types": t, "instances": i}
	t, i = bleveRegistry.FragmenterTypesAndInstances()
	br["Fragmenter"] = map[string][]string{"types": t, "instances": i}
	t, i = bleveRegistry.HighlighterTypesAndInstances()
	br["Highlighter"] = map[string][]string{"types": t, "instances": i}
	t, i = bleveRegistry.KVStoreTypesAndInstances()
	br["KVStore"] = map[string][]string{"types": t, "instances": i}
	t, i = bleveRegistry.TokenFilterTypesAndInstances()
	br["TokenFilter"] = map[string][]string{"types": t, "instances": i}
	t, i = bleveRegistry.TokenMapTypesAndInstances()
	br["TokenMap"] = map[string][]string{"types": t, "instances": i}
	t, i = bleveRegistry.TokenizerTypesAndInstances()
	br["Tokenizer"] = map[string][]string{"types": t, "instances": i}

	m["regBleve"] = br
}
Exemple #3
0
func ListTokenizerTypes(w http.ResponseWriter, req *http.Request) {
	// built in char filter names
	tokenizerTypes, _ := registry.TokenizerTypesAndInstances()

	sort.Strings(tokenizerTypes)

	rv := struct {
		Status         string   `json:"status"`
		TokenizerTypes []string `json:"tokenizer_types"`
	}{
		Status:         "ok",
		TokenizerTypes: tokenizerTypes,
	}
	mustEncode(w, rv)
}
Exemple #4
0
func ListTokenizerNames(w http.ResponseWriter, req *http.Request) {
	indexMapping := bleve.NewIndexMapping()

	// read the request body
	requestBody, err := ioutil.ReadAll(req.Body)
	if err != nil {
		showError(w, req, fmt.Sprintf("error reading request body: %v", err), 400)
		return
	}

	// interpret request body as index mapping
	if len(requestBody) > 0 {
		requestBody, err = CleanseJSON(requestBody)
		if err != nil {
			showError(w, req, fmt.Sprintf("error preparing index mapping: %v", err), 400)
			return
		}
		err = json.Unmarshal(requestBody, &indexMapping)
		if err != nil {
			showError(w, req, fmt.Sprintf("error parsing index mapping: %v", err), 400)
			return
		}
	}

	// built in char filter names
	_, tokenizerNames := registry.TokenizerTypesAndInstances()
	// add custom char filter names
	for name := range indexMapping.CustomAnalysis.Tokenizers {
		tokenizerNames = append(tokenizerNames, name)
	}

	sort.Strings(tokenizerNames)

	rv := struct {
		Status     string   `json:"status"`
		Tokenizers []string `json:"tokenizers"`
	}{
		Status:     "ok",
		Tokenizers: tokenizerNames,
	}
	mustEncode(w, rv)
}
Exemple #5
0
	Use:   "registry",
	Short: "registry lists the bleve components compiled into this executable",
	Long:  `The registry command will list all of the bleve components compiled into this executable.`,
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		// override to do nothing
		return nil
	},
	PersistentPostRunE: func(cmd *cobra.Command, args []string) error {
		// override to do nothing
		return nil
	},
	Run: func(cmd *cobra.Command, args []string) {
		types, instances := registry.CharFilterTypesAndInstances()
		printType("Char Filter", types, instances)

		types, instances = registry.TokenizerTypesAndInstances()
		printType("Tokenizer", types, instances)

		types, instances = registry.TokenMapTypesAndInstances()
		printType("Token Map", types, instances)

		types, instances = registry.TokenFilterTypesAndInstances()
		printType("Token Filter", types, instances)

		types, instances = registry.AnalyzerTypesAndInstances()
		printType("Analyzer", types, instances)

		types, instances = registry.DateTimeParserTypesAndInstances()
		printType("Date Time Parser", types, instances)

		types, instances = registry.KVStoreTypesAndInstances()