當前位置: 首頁>>代碼示例>>Golang>>正文


Golang mapping.IndexMapping類代碼示例

本文整理匯總了Golang中github.com/blevesearch/bleve/mapping.IndexMapping的典型用法代碼示例。如果您正苦於以下問題:Golang IndexMapping類的具體用法?Golang IndexMapping怎麽用?Golang IndexMapping使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了IndexMapping類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Searcher

func (q *TermQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
	field := q.Field
	if q.Field == "" {
		field = m.DefaultSearchField()
	}
	return searcher.NewTermSearcher(i, q.Term, field, q.Boost.Value(), explain)
}
開發者ID:bcampbell,項目名稱:bleve,代碼行數:7,代碼來源:term.go

示例2: Searcher

func (q *NumericRangeQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
	field := q.Field
	if q.Field == "" {
		field = m.DefaultSearchField()
	}
	return searcher.NewNumericRangeSearcher(i, q.Min, q.Max, q.InclusiveMin, q.InclusiveMax, field, q.Boost.Value(), explain)
}
開發者ID:bcampbell,項目名稱:bleve,代碼行數:7,代碼來源:numeric_range.go

示例3: Searcher

func (q *RegexpQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
	field := q.Field
	if q.Field == "" {
		field = m.DefaultSearchField()
	}
	err := q.compile()
	if err != nil {
		return nil, err
	}

	return searcher.NewRegexpSearcher(i, q.compiled, field, q.Boost.Value(), explain)
}
開發者ID:bcampbell,項目名稱:bleve,代碼行數:12,代碼來源:regexp.go

示例4: Searcher

func (q *DateRangeQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
	min, max, err := q.parseEndpoints()
	if err != nil {
		return nil, err
	}

	field := q.Field
	if q.Field == "" {
		field = m.DefaultSearchField()
	}

	return searcher.NewNumericRangeSearcher(i, min, max, q.InclusiveStart, q.InclusiveEnd, field, q.Boost.Value(), explain)
}
開發者ID:bcampbell,項目名稱:bleve,代碼行數:13,代碼來源:date_range.go

示例5: Searcher

func (q *WildcardQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
	field := q.Field
	if q.Field == "" {
		field = m.DefaultSearchField()
	}
	if q.compiled == nil {
		var err error
		q.compiled, err = q.convertToRegexp()
		if err != nil {
			return nil, err
		}
	}

	return searcher.NewRegexpSearcher(i, q.compiled, field, q.Boost.Value(), explain)
}
開發者ID:bcampbell,項目名稱:bleve,代碼行數:15,代碼來源:wildcard.go

示例6: Searcher

func (q *allMatchQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {

	field := q.FieldVal
	if q.FieldVal == "" {
		field = m.DefaultSearchField()
	}
	analyzerName := m.AnalyzerNameForPath(field)
	analyzer := m.AnalyzerNamed(analyzerName)
	tokens := analyzer.Analyze([]byte(q.Match))
	if len(tokens) == 0 {
		noneQuery := bleve.NewMatchNoneQuery()
		return noneQuery.Searcher(i, m, explain)
	}

	tqs := make([]query.Query, len(tokens))
	for i, token := range tokens {
		tq := bleve.NewTermQuery(string(token.Term))
		tq.SetField(field)
		tq.SetBoost(q.BoostVal)
		tqs[i] = tq
	}
	allQuery := bleve.NewConjunctionQuery(tqs...)
	allQuery.SetBoost(q.BoostVal)
	return allQuery.Searcher(i, m, explain)
}
開發者ID:pmezard,項目名稱:apec,代碼行數:25,代碼來源:query_allmatch.go

示例7: Searcher

func (q *MatchPhraseQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
	field := q.Field
	if q.Field == "" {
		field = m.DefaultSearchField()
	}

	analyzerName := ""
	if q.Analyzer != "" {
		analyzerName = q.Analyzer
	} else {
		analyzerName = m.AnalyzerNameForPath(field)
	}
	analyzer := m.AnalyzerNamed(analyzerName)
	if analyzer == nil {
		return nil, fmt.Errorf("no analyzer named '%s' registered", q.Analyzer)
	}

	tokens := analyzer.Analyze([]byte(q.MatchPhrase))
	if len(tokens) > 0 {
		phrase := tokenStreamToPhrase(tokens)
		phraseQuery := NewPhraseQuery(phrase, field)
		phraseQuery.SetBoost(q.Boost.Value())
		return phraseQuery.Searcher(i, m, explain)
	}
	noneQuery := NewMatchNoneQuery()
	return noneQuery.Searcher(i, m, explain)
}
開發者ID:bcampbell,項目名稱:bleve,代碼行數:27,代碼來源:match_phrase.go

示例8: Searcher

func (q *MatchQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {

	field := q.Field
	if q.Field == "" {
		field = m.DefaultSearchField()
	}

	analyzerName := ""
	if q.Analyzer != "" {
		analyzerName = q.Analyzer
	} else {
		analyzerName = m.AnalyzerNameForPath(field)
	}
	analyzer := m.AnalyzerNamed(analyzerName)

	if analyzer == nil {
		return nil, fmt.Errorf("no analyzer named '%s' registered", q.Analyzer)
	}

	tokens := analyzer.Analyze([]byte(q.Match))
	if len(tokens) > 0 {

		tqs := make([]Query, len(tokens))
		if q.Fuzziness != 0 {
			for i, token := range tokens {
				query := NewFuzzyQuery(string(token.Term))
				query.SetFuzziness(q.Fuzziness)
				query.SetPrefix(q.Prefix)
				query.SetField(field)
				query.SetBoost(q.Boost.Value())
				tqs[i] = query
			}
		} else {
			for i, token := range tokens {
				tq := NewTermQuery(string(token.Term))
				tq.SetField(field)
				tq.SetBoost(q.Boost.Value())
				tqs[i] = tq
			}
		}

		switch q.Operator {
		case MatchQueryOperatorOr:
			shouldQuery := NewDisjunctionQuery(tqs)
			shouldQuery.SetMin(1)
			shouldQuery.SetBoost(q.Boost.Value())
			return shouldQuery.Searcher(i, m, explain)

		case MatchQueryOperatorAnd:
			mustQuery := NewConjunctionQuery(tqs)
			mustQuery.SetBoost(q.Boost.Value())
			return mustQuery.Searcher(i, m, explain)

		default:
			return nil, fmt.Errorf("unhandled operator %d", q.Operator)
		}
	}
	noneQuery := NewMatchNoneQuery()
	return noneQuery.Searcher(i, m, explain)
}
開發者ID:bcampbell,項目名稱:bleve,代碼行數:60,代碼來源:match.go

示例9: newIndexUsing

func newIndexUsing(path string, mapping mapping.IndexMapping, indexType string, kvstore string, kvconfig map[string]interface{}) (*indexImpl, error) {
	// first validate the mapping
	err := mapping.Validate()
	if err != nil {
		return nil, err
	}

	if kvconfig == nil {
		kvconfig = map[string]interface{}{}
	}

	if kvstore == "" {
		return nil, fmt.Errorf("bleve not configured for file based indexing")
	}

	rv := indexImpl{
		path: path,
		name: path,
		m:    mapping,
		meta: newIndexMeta(indexType, kvstore, kvconfig),
	}
	rv.stats = &IndexStat{i: &rv}
	// at this point there is hope that we can be successful, so save index meta
	if path != "" {
		err = rv.meta.Save(path)
		if err != nil {
			return nil, err
		}
		kvconfig["create_if_missing"] = true
		kvconfig["error_if_exists"] = true
		kvconfig["path"] = indexStorePath(path)
	} else {
		kvconfig["path"] = ""
	}

	// open the index
	indexTypeConstructor := registry.IndexTypeConstructorByName(rv.meta.IndexType)
	if indexTypeConstructor == nil {
		return nil, ErrorUnknownIndexType
	}

	rv.i, err = indexTypeConstructor(rv.meta.Storage, kvconfig, Config.analysisQueue)
	if err != nil {
		return nil, err
	}
	err = rv.i.Open()
	if err != nil {
		if err == index.ErrorUnknownStorageType {
			return nil, ErrorUnknownStorageType
		}
		return nil, err
	}

	// now persist the mapping
	mappingBytes, err := json.Marshal(mapping)
	if err != nil {
		return nil, err
	}
	err = rv.i.SetInternal(mappingInternalKey, mappingBytes)
	if err != nil {
		return nil, err
	}

	// mark the index as open
	rv.mutex.Lock()
	defer rv.mutex.Unlock()
	rv.open = true
	indexStats.Register(&rv)
	return &rv, nil
}
開發者ID:bcampbell,項目名稱:bleve,代碼行數:70,代碼來源:index_impl.go


注:本文中的github.com/blevesearch/bleve/mapping.IndexMapping類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。