bugfixes more search results and dump restore options

This commit is contained in:
ston1th 2016-11-17 21:21:16 +01:00
commit 3cd460318a
124 changed files with 3915 additions and 9579 deletions

View file

@ -7,13 +7,13 @@
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//go:generate nex query_string.nex
//go:generate sed -i "" -e s/Lexer/lexer/g query_string.nn.go
//go:generate sed -i "" -e s/Newlexer/newLexer/g query_string.nn.go
//go:generate sed -i "" -e s/debuglexer/debugLexer/g query_string.nn.go
//go:generate go fmt query_string.nn.go
//go:generate go tool yacc -o query_string.y.go query_string.y
//go:generate sed -i "" -e 1d query_string.y.go
//go:generate sed -i.tmp -e 1d query_string.y.go
//go:generate rm query_string.y.go.tmp
// note: OSX sed and gnu sed handle the -i (in-place) option differently.
// using -i.tmp works on both, at the expense of having to remove
// the unsightly .tmp files
package bleve
@ -25,22 +25,21 @@ import (
var debugParser bool
var debugLexer bool
func parseQuerySyntax(query string, mapping *IndexMapping) (rq Query, err error) {
lex := newLexerWrapper(newLexer(strings.NewReader(query)))
func parseQuerySyntax(query string) (rq Query, err error) {
lex := newLexerWrapper(newQueryStringLex(strings.NewReader(query)))
doParse(lex)
if len(lex.errs) > 0 {
return nil, fmt.Errorf(strings.Join(lex.errs, "\n"))
} else {
return lex.query, nil
}
return lex.query, nil
}
func doParse(lex *lexerWrapper) {
defer func() {
r := recover()
if r != nil {
lex.Error("Errors while parsing.")
lex.errs = append(lex.errs, fmt.Sprintf("parse error: %v", r))
}
}()
@ -54,23 +53,22 @@ const (
)
type lexerWrapper struct {
nex yyLexer
lex yyLexer
errs []string
query *booleanQuery
}
func newLexerWrapper(nex yyLexer) *lexerWrapper {
func newLexerWrapper(lex yyLexer) *lexerWrapper {
return &lexerWrapper{
nex: nex,
errs: []string{},
lex: lex,
query: NewBooleanQuery(nil, nil, nil),
}
}
func (this *lexerWrapper) Lex(lval *yySymType) int {
return this.nex.Lex(lval)
func (l *lexerWrapper) Lex(lval *yySymType) int {
return l.lex.Lex(lval)
}
func (this *lexerWrapper) Error(s string) {
this.errs = append(this.errs, s)
func (l *lexerWrapper) Error(s string) {
l.errs = append(l.errs, s)
}