2968d3538a
removed analyzers (these are now built as needed through config) removed html chacter filter (now built as needed through config) added missing license header changed constructor signature of filters that cannot return errors filter constructors that can have errors, now have Must variant which panics change cdl2 tokenizer into filter (should only see lower-case input) new top level index api, closes #5 refactored index tests to not rely directly on analyzers moved query objects to top-level new top level search api, closes #12 top score collector allows skipping results index mapping supports _all by default, closes #3 and closes #6 index mapping supports disabled sections, closes #7 new http sub package with reusable http.Handler's, closes #22
138 lines
2.2 KiB
Plaintext
138 lines
2.2 KiB
Plaintext
%{
|
|
package bleve
|
|
import "log"
|
|
|
|
func logDebugGrammar(format string, v ...interface{}) {
|
|
if debugParser {
|
|
log.Printf(format, v...)
|
|
}
|
|
}
|
|
%}
|
|
|
|
%union {
|
|
s string
|
|
n int
|
|
f float64}
|
|
|
|
%token STRING PHRASE PLUS MINUS COLON BOOST LPAREN RPAREN INT STRING
|
|
|
|
%%
|
|
|
|
input:
|
|
searchParts {
|
|
logDebugGrammar("INPUT")
|
|
};
|
|
|
|
searchParts:
|
|
searchPart searchParts {
|
|
logDebugGrammar("SEARCH PARTS")
|
|
}
|
|
|
|
|
searchPart {
|
|
logDebugGrammar("SEARCH PART")
|
|
};
|
|
|
|
searchPart:
|
|
searchPrefix searchBase searchSuffix {
|
|
|
|
};
|
|
|
|
|
|
searchPrefix:
|
|
/* empty */ {
|
|
}
|
|
|
|
|
searchMustMustNot {
|
|
|
|
}
|
|
;
|
|
|
|
searchMustMustNot:
|
|
PLUS {
|
|
logDebugGrammar("PLUS")
|
|
parsingMust = true
|
|
}
|
|
|
|
|
MINUS {
|
|
logDebugGrammar("MINUS")
|
|
parsingMustNot = true
|
|
};
|
|
|
|
searchBase:
|
|
STRING {
|
|
str := $1.s
|
|
logDebugGrammar("STRING - %s", str)
|
|
q := NewMatchQuery(str).SetField(parsingDefaultField)
|
|
if parsingMust {
|
|
parsingMustList.AddQuery(q)
|
|
parsingMust = false
|
|
} else if parsingMustNot {
|
|
parsingMustNotList.AddQuery(q)
|
|
parsingMustNot = false
|
|
} else {
|
|
parsingShouldList.AddQuery(q)
|
|
}
|
|
}
|
|
|
|
|
PHRASE {
|
|
phrase := $1.s
|
|
logDebugGrammar("PHRASE - %s", phrase)
|
|
q := NewMatchPhraseQuery(phrase).SetField(parsingDefaultField)
|
|
if parsingMust {
|
|
parsingMustList.AddQuery(q)
|
|
parsingMust = false
|
|
} else if parsingMustNot {
|
|
parsingMustNotList.AddQuery(q)
|
|
parsingMustNot = false
|
|
} else {
|
|
parsingShouldList.AddQuery(q)
|
|
}
|
|
}
|
|
|
|
|
STRING COLON STRING {
|
|
field := $1.s
|
|
str := $3.s
|
|
logDebugGrammar("FIELD - %s STRING - %s", field, str)
|
|
q := NewMatchQuery(str).SetField(field)
|
|
if parsingMust {
|
|
parsingMustList.AddQuery(q)
|
|
parsingMust = false
|
|
} else if parsingMustNot {
|
|
parsingMustNotList.AddQuery(q)
|
|
parsingMustNot = false
|
|
} else {
|
|
parsingShouldList.AddQuery(q)
|
|
}
|
|
}
|
|
|
|
|
STRING COLON PHRASE {
|
|
field := $1.s
|
|
phrase := $3.s
|
|
logDebugGrammar("FIELD - %s PHRASE - %s", field, phrase)
|
|
q := NewMatchPhraseQuery(phrase).SetField(field)
|
|
if parsingMust {
|
|
parsingMustList.AddQuery(q)
|
|
parsingMust = false
|
|
} else if parsingMustNot {
|
|
parsingMustNotList.AddQuery(q)
|
|
parsingMustNot = false
|
|
} else {
|
|
parsingShouldList.AddQuery(q)
|
|
}
|
|
};
|
|
|
|
|
|
searchBoost:
|
|
BOOST INT {
|
|
boost := $1.n
|
|
logDebugGrammar("BOOST %d", boost)
|
|
}
|
|
|
|
searchSuffix:
|
|
/* empty */ {
|
|
|
|
}
|
|
|
|
|
searchBoost {
|
|
|
|
}; |