Example #1
0
func FetchByRelevanceAndDistance(s *solr.Solr, keywords string, lat float64, long float64, labels []string, startIndex int, limit int, maxDistance int) (result *solr.Result, err error) {

	var filterQuery string
	if len(labels) > 0 {
		filterQuery = "labels: (" + strings.Join(labels, " AND ") + ")"
	}
	query := solr.NewQuery(solr.AddFuzzyLogic(keywords), startIndex, limit)
	query.DefType(`edismax`)
	query.FilterQuery(filterQuery)
	query.QueryFields(`keywords^0.2 skills^0.7`)
	query.FilterQuery(`accounttype:FREE`)
	query.SpacialParam(lat, long, `location`, maxDistance)
	query.Sort(`score desc`)
	query.BoostFunction(solr.Recip(`geodist()`, 1, 1, 1, 4))
	query.AddHighlighter(`skills`, 2)

	result, err = s.Search(query)
	for _, val := range result.Highlights {
		fmt.Println(val.Id)
		if terms, ok := val.HighlightTerms[`skills`].([]interface{}); ok {
			for _, v := range terms {
				fmt.Println(v)
			}
		}

	}
	return

}
Example #2
0
func FetchSampleRecordsByRelevance(s *solr.Solr, keywords string, startIndex int, limit int) (result *solr.Result, err error) {

	query := solr.NewQuery(solr.AddFuzzyLogic(keywords), startIndex, limit)
	query.DefType(`edismax`)
	query.QueryFields(`keywords^0.2 skills^0.7`)
	query.FilterQuery(`accounttype:EXAMPLE`)
	query.Sort(`score desc`)
	query.SpellcheckQuery(keywords)
	result, err = s.Search(query)

	return

}