By ss_matches


2019-05-15 16:46:54 8 Comments

I am using reactive search to search against my elastic search index. I would like to have one field in the index be a default. For instance, in this app at the root level, you choose a project. When you progress farther into the app you can search. Right now, you are searching against all projects.

I have made a toggle button that I hide with css. This approach is a hack, and works until I clear all filters. That toggle button that no one sees clears the project, then I see results from all projects again.

        <ToggleButton
          style={{ display: 'none' }}
          componentId="project"
          dataField="project"
          defaultSelected={[projectId]}
          URLParams={false}
          multiSelect={false}
          showFilter={false}
          data={[
            { label: 'Project', value: projectId },
          ]}
          className="project"
        />

Is there a way to set a default search criteria?

1 comments

@Sachin Dongare 2019-08-06 14:52:05

Yes sure, You can set default search criteria for this,
Set defaultQuery in ReactiveList component and match the value which has to be default.

Like this:

<ReactiveList
    componentId="results"
    dataField={datafield}
    sortBy={sort}
    react={{
        and: Query
    }}
    defaultQuery={this.defaultQuery}
/>

this.defaultQuery = function() {
    return {
        match: { dataField: "Value" }
    }
};

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] Is there a way to render ReactiveList conditionally

  • 2019-10-17 20:38:19
  • user3125823
  • 36 View
  • 0 Score
  • 1 Answer
  • Tags:   reactivesearch

1 Answered Questions

[SOLVED] Hide or minimise search facet component after making a selection

1 Answered Questions

[SOLVED] How to display detail page from search results in ResultCard?

1 Answered Questions

[SOLVED] Is there a way to see the query produced by ReactiveSearch

1 Answered Questions

[SOLVED] Reactive Search MultiDropdownList not finding dataField

1 Answered Questions

[SOLVED] Submitting a search query with ReactiveSearch

  • 2018-09-25 21:10:12
  • user3125823
  • 400 View
  • 1 Score
  • 1 Answer
  • Tags:   reactivesearch

1 Answered Questions

[SOLVED] ReactiveList related searches

  • 2018-08-18 16:23:03
  • user3125823
  • 64 View
  • 1 Score
  • 1 Answer
  • Tags:   reactivesearch

Sponsored Content