summaryrefslogtreecommitdiffstats
path: root/modules/indexer/indexer.go
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2017-09-16 13:16:21 -0700
committerLauris BH <lauris@nix.lv>2017-09-16 23:16:21 +0300
commitb0f7457d9ef6e16d4a3197f7544035d5d387e201 (patch)
treedbe6a9b3b74f9a4a6eaa0c0cfe59fa08509edccc /modules/indexer/indexer.go
parent52e11b24bf5e395d83ea58c1b0fd6922efe16add (diff)
downloadgitea-b0f7457d9ef6e16d4a3197f7544035d5d387e201.tar.gz
gitea-b0f7457d9ef6e16d4a3197f7544035d5d387e201.zip
Improve issue search (#2387)
* Improve issue indexer * Fix new issue sqlite bug * Different test indexer paths for each db * Add integration indexer paths to make clean
Diffstat (limited to 'modules/indexer/indexer.go')
-rw-r--r--modules/indexer/indexer.go37
1 files changed, 33 insertions, 4 deletions
diff --git a/modules/indexer/indexer.go b/modules/indexer/indexer.go
index 2b7b76f7f2..5ee813412d 100644
--- a/modules/indexer/indexer.go
+++ b/modules/indexer/indexer.go
@@ -5,10 +5,39 @@
package indexer
import (
- "code.gitea.io/gitea/models"
+ "fmt"
+ "strconv"
+
+ "github.com/blevesearch/bleve"
+ "github.com/blevesearch/bleve/search/query"
)
-// NewContext start indexer service
-func NewContext() {
- models.InitIssueIndexer()
+// indexerID a bleve-compatible unique identifier for an integer id
+func indexerID(id int64) string {
+ return strconv.FormatInt(id, 36)
+}
+
+// idOfIndexerID the integer id associated with an indexer id
+func idOfIndexerID(indexerID string) (int64, error) {
+ id, err := strconv.ParseInt(indexerID, 36, 64)
+ if err != nil {
+ return 0, fmt.Errorf("Unexpected indexer ID %s: %v", indexerID, err)
+ }
+ return id, nil
+}
+
+// numericEqualityQuery a numeric equality query for the given value and field
+func numericEqualityQuery(value int64, field string) *query.NumericRangeQuery {
+ f := float64(value)
+ tru := true
+ q := bleve.NewNumericRangeInclusiveQuery(&f, &f, &tru, &tru)
+ q.SetField(field)
+ return q
+}
+
+func newMatchPhraseQuery(matchPhrase, field, analyzer string) *query.MatchPhraseQuery {
+ q := bleve.NewMatchPhraseQuery(matchPhrase)
+ q.FieldVal = field
+ q.Analyzer = analyzer
+ return q
}