0
0
Fork 0

attempt to support google app engine

the default configuration, which sets the default kv engine
to boltdb is now done in file protected with the !appengine
build tag.  this at least lets the analysis-wizzard app
run locally in the appengine simulator.

this still has not been tested on the real appengine, and further
changes may be required.
This commit is contained in:
Marty Schoch 2016-07-29 21:27:23 -04:00
parent b158fb147d
commit 389e18a779
4 changed files with 45 additions and 2 deletions

View File

@ -17,7 +17,6 @@ import (
"github.com/blevesearch/bleve/analysis/datetime_parsers/datetime_optional"
"github.com/blevesearch/bleve/index"
"github.com/blevesearch/bleve/index/store/boltdb"
"github.com/blevesearch/bleve/index/upside_down"
"github.com/blevesearch/bleve/registry"
"github.com/blevesearch/bleve/search/highlight/highlighters/html"
@ -59,7 +58,7 @@ func init() {
Config.DefaultHighlighter = html.Name
// default kv store
Config.DefaultKVStore = boltdb.Name
Config.DefaultKVStore = ""
// default index
Config.DefaultIndexType = upside_down.Name
@ -71,6 +70,8 @@ func init() {
bleveExpVar.Add("bootDuration", int64(bootDuration))
indexStats = NewIndexStats()
bleveExpVar.Set("indexes", indexStats)
initDisk()
}
var logger = log.New(ioutil.Discard, "bleve", log.LstdFlags)

18
config_app.go Normal file
View File

@ -0,0 +1,18 @@
// Copyright (c) 2014 Couchbase, Inc.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
// +build appengine
package bleve
// in the appengine environment we cannot support disk based indexes
// so we do no extra configuration in this method
func initDisk() {
}

20
config_disk.go Normal file
View File

@ -0,0 +1,20 @@
// Copyright (c) 2014 Couchbase, Inc.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
// +build !appengine
package bleve
import "github.com/blevesearch/bleve/index/store/boltdb"
// in normal environments we configure boltdb as the default storage
func initDisk() {
// default kv store
Config.DefaultKVStore = boltdb.Name
}

View File

@ -109,6 +109,10 @@ func newIndexUsing(path string, mapping *IndexMapping, indexType string, kvstore
kvconfig = map[string]interface{}{}
}
if kvstore == "" {
return nil, fmt.Errorf("bleve not configured for file based indexing")
}
rv := indexImpl{
path: path,
name: path,