Closed edwinsiebel closed 3 years ago
Any reaction from the team?
@edwinsiebel You can find the defaultQuery
working here https://codesandbox.io/s/dawn-resonance-2b047?file=/src/index.js.
FYI, the defaultQuery
would affect the suggestions query in DataSearch
. If you want to update results then please use customQuery
instead.
@edwinsiebel I'm facing the same issue when I have a customQuery already defined, and I want to use defaultQuery as well to adjust the suggestions query. Were you able to figure this out?
No, unfortunately not. Have tried various implementations, however no results.
@bietkul , seems more have problems with this situation. Can you make a working example, as described by @rgb-panda ?
@rgb-panda @edwinsiebel Sharing an example with both customQuery
and defaultQuery
props in DataSearch
component. I don't see any issues with that. Make sure you're using the latest version of the libs even then the issue persists feel free to re-open the issue with a reproducible example.
https://codesandbox.io/s/dawn-resonance-2b047?file=/src/index.js
@edwinsiebel I know this issue is closed, but I noticed in your steps to reproduce code you're not returning the query. I came across this same issue when using the documentation example for defaultQuery
, so one of the following changes may get things working for you:
<DataSearch
componentId="q"
defaultQuery={ ( value, props ) => ({
query: {
terms: {
country: [ "India" ]
}
}
}) }
or
<DataSearch
componentId="q"
defaultQuery={ ( value, props ) => {
return {
query: {
terms: {
country: [ "India" ]
}
}
}
}}
Edit: Opened a PR in the docs repo to fix this
Hi @djsiroky ,
Thanks for the heads up. Will have to work on it again soon, so will take this change into account. And great that you updated the doc's as well!
Looking at this almost a year later, and still face the same issue when trying to adjust the suggestions query to limit what it's doing. It seems to work only the first time, then any other time after the first search it reverts back to the default query with includes : [*] and size: 100
my query below is completely ignored
defaultQuery={() => ( { size: "10", _source: { includes: ["my_field"] } } ) }
tried to provide the full query as it is in the library default with just size and _source difference, and again it just works the first time. After my first actual search, any subsequent suggestion query ignores it
defaultQuery={(value,props) => ( { "query": { "bool": { "must": [ { "bool": { "must": [ { "bool": { "should": [ { "multi_match": { "query": value, "fields": [ "my_field" ], "type": "cross_fields", "operator": "and" } }, { "multi_match": { "query": value, "fields": [ "my_field" ], "type": "phrase", "operator": "and" } }, { "multi_match": { "query": value, "fields": [ "my_field" ], "type": "phrase_prefix", "operator": "and" } } ], "minimum_should_match": "1" } } ] } } ] } }, "size": 10, "_source":["my_field"] } ) }
Affected Projects React
Library Version: x.y.z stable,
"@appbaseio/reactivesearch": "^3.14"
Describe the bug When using a
DataSearch
component with autosuggest, and a custom render method, the defaultQuery is not applied. This is stated in the documentation.To Reproduce Steps to reproduce the behavior:
See screenshot: no 'India` is applied Expected behavior The query should apply/add/merge the (custom) defaultQuery with the defaultQuery.
Screenshots
Desktop (please complete the following information):
Additional context