Open orange-jacky opened 5 years ago
Setting Fields
on the request does not scope the search, instead it instructs bleve to load stored fields with those names.
Scoping to a field happens at the query level, but it can only be set to a single field, like:
query.Field = "cnname"
In order to search and match against a limited set of fields, you would have to create N queries (each 1 restricted to a single field), and then place all of them inside a DisjunctionQuery.
could you improve it just like elasticsearch usage
I don't know what that means.
elasticsearch can search and match some text against a limited set of fields in one request , can bleve support it ?
could you write a demo about Scoping to a field happens at the query level, but it can only be set to a single field, like: query.Field = "cnname"
i look in godoc and can't find how to use query.Field
I just described how to do it with a single request. The complication in what I proposed is that it requires multiple query clauses. It is a bit cumbersome, but unless you actually index a custom composite field (something ES supports that we do not) it will not perform differently. Can you show me how you would represent the query in ES?
On Fri, Jun 14, 2019 at 9:17 AM orange-jacky notifications@github.com wrote:
elasticsearch can search and match some text against a limited set of fields in one request , can bleve support it ?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/blevesearch/bleve/issues/1249?email_source=notifications&email_token=AACIZH3ILG5P26P3JHR3MBTP2OK7NA5CNFSM4HYFCVW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXWYMWY#issuecomment-502105691, or mute the thread https://github.com/notifications/unsubscribe-auth/AACIZHYB5N4NU7FQ642DSDLP2OK7NANCNFSM4HYFCVWQ .
There is currently not an example of this in the godocs. The FieldableQuery types support this interface:
https://godoc.org/github.com/blevesearch/bleve/search/query#FieldableQuery
you can look in the flowing url https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-multi-match-query.html
such as GET /_search { "query": { "multi_match" : { "query": "this is a test", "fields": [ "subject", "message" ] } } }
Thanks, what you are asking for is for us to add a new query type called MultiMatch.
yes
hi, when to support a new query type called MultiMatch, i need to use it
@orange-jacky this will be a useful addition to the project, but currently no one is working on implementing it. While the feature does not look that complicated, from the documentation it is apparent that there are many modes of operation, so it will not be trivial either.
i have write a demo by your guide(search and match against a limited set of fields, you would have to create N queries (each 1 restricted to a single field), and then place all of them inside a DisjunctionQuery.)
param := "bj"
queryId := query.NewMatchPhraseQuery(param)
queryId.SetField("id")
queryCnname := query.NewMatchPhraseQuery(param)
queryCnname.SetField("cnname")
queryCitycode := query.NewMatchPhraseQuery(param)
queryCitycode.SetField("citycode")
queryCitycn := query.NewMatchPhraseQuery(param)
queryCitycn.SetField("citycn")
queryEnname := query.NewMatchPhraseQuery(param)
queryEnname.SetField("enname")
queryCountry := query.NewMatchPhraseQuery(param)
queryCountry.SetField("country")
disQuery := bleve.NewDisjunctionQuery()
disQuery.AddQuery(queryId, queryCnname, queryCitycode, queryCitycn, queryEnname, queryCountry)
searchRequest := bleve.NewSearchRequestOptions(disQuery, 1000, 0, true)
searchRequest.Fields = []string{"id", "cnname", "citycode", "citycn", "enname", "country"}
searchRequest.SortBy([]string{"-id"})
func buildGlobalAirportIndexMapping() (mapping.IndexMapping, error) { // a generic reusable mapping for english text englishTextFieldMapping := bleve.NewTextFieldMapping() englishTextFieldMapping.Analyzer = en.AnalyzerName
}
my issue is that i want to match fields []string{"id", "cnname", "citycode", "citycn", "enname", "country"}, in fact it query all fileds, how to make it only match fields []string{"id", "cnname", "citycode", "citycn", "enname", "country"}
query := bleve.NewMatchPhraseQuery("pe") searchRequest := bleve.NewSearchRequestOptions(query, 1000, 0, true) searchRequest.Fields = []string{"id", "cnname", "citycode", "citycn", "enname", "country"} searchRequest.SortBy([]string{"-id"})