You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-20Lines changed: 32 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# App Search Reference UI
2
2
3
3
The Reference UI is a configurable, generic UI meant to work with
4
-
any [App Search](https://www.elastic.co/cloud/app-search-service) Engine. It
4
+
any [App Search](https://www.elastic.co/cloud/search-lib-service) Engine. It
5
5
can serve as a simple demo, a functional test for your Engine data,
6
6
or as a code reference when building out your own App Search
7
7
UI.
@@ -27,7 +27,7 @@ Run the following commands to start this application:
27
27
# Run the `cd` command to change the current directory to the
28
28
# location of your downloaded Reference UI. Replace the path
29
29
# below with the actual path of your project.
30
-
cd~/Downloads/app-search-reference-ui
30
+
cd~/Downloads/search-lib-reference-ui
31
31
32
32
# Run this to set everything up
33
33
npm install
@@ -57,7 +57,7 @@ The following is a complete list of options available for configuration in [engi
57
57
|`urlField`| String | optional | A field with a url to use as a link in results. |
58
58
|`urlFieldTemplate`| String | optional | Instead of urlField, you can provide a URL "template" here, which lets you build a URL from other fields. ex: "https://www.example.com/{{id}}".|
59
59
|`sortFields`| Array[String]| required | A list of fields that will be used for sort options. |
60
-
|`facets`| Array[String]| required | A list of fields that will be available as "facet" filters. Read more about facets within the [App Search documentation](https://swiftype.com/documentation/app-search/guides/facets). |
60
+
|`facets`| Array[String]| required | A list of fields that will be available as "facet" filters. Read more about facets within the [App Search documentation](https://swiftype.com/documentation/search-lib/guides/facets). |
61
61
62
62
### External configuration
63
63
@@ -71,7 +71,7 @@ You can follow the previous steps, but then you will need to configure
71
71
[engine.json](src/config/engine.json).
72
72
73
73
To do so, make a copy of [engine.json.example](src/config/engine.json.example),
74
-
rename it to `engine.json` and configure with your Engine's specific details.
74
+
rename it to `engine.json` and configure it with your Engine's specific details.
@@ -92,13 +92,13 @@ Logically, the pieces of this application fit together like this:
92
92
|
93
93
( State manager ) ( Syncs state with URL )
94
94
------------------- --------------
95
-
| AppSearchDriver | <--> | URLManager |
95
+
| SearchDriver | <--> | URLManager |
96
96
------------------- --------------
97
97
|
98
98
| actions / state
99
99
v
100
100
---------------------
101
-
| AppSearchProvider | ( Driver to React glue )
101
+
| SearchProvider | ( Driver to React glue )
102
102
---------------------
103
103
|
104
104
| context
@@ -115,9 +115,16 @@ Logically, the pieces of this application fit together like this:
115
115
116
116
That corresponds to the code and file structure in the following way:
117
117
118
-
**src/app-search**
118
+
**src/search-lib**
119
119
120
-
This holds the `AppSearchDriver`, the `URLManager`, and `AppSearchProvider`
120
+
Everything in this directory for now should be thought of as a separate library.
121
+
The goal eventually is to actually separate this out into a library of its own,
122
+
so when composing a UI you'd simply need to focus on creating components
123
+
from actions and state, and not all of the plumbing that goes into managing
124
+
that state. For now though, it's included in this reference as a pattern
125
+
that can be followed.
126
+
127
+
This holds the `SearchDriver`, the `URLManager`, and `SearchProvider`
121
128
from the diagram above. This is where all of the core application logic lives.
122
129
The interface to all of this logic is a set of "actions" and "state" that are
123
130
passed down in a React [Context](https://reactjs.org/docs/context.html). Those
@@ -158,20 +165,13 @@ So, for instance, a `SearchBox` component might be wired up to call the
158
165
value. A `Results` component could then simply iterate through the `results`
159
166
from state to render search results.
160
167
161
-
Everything in this directory for now should be thought of as a separate library.
162
-
The goal eventually is to actually separate this out into a library of it's own,
163
-
so when composing a UI you'd simply need to focus on creating components
164
-
from actions and state, and not all of the plumbing that goes into managing
165
-
that state. For now though, it's included in this reference as a pattern
166
-
that can be followed.
167
-
168
168
**src/containers**
169
169
170
170
Components in this UI are separated into "Containers" and "Components". These
171
171
can be thought of as "Logic" and "View", respectively.
172
172
173
173
"Containers" are "connected" to the "context" via a "Higher Order Component"
174
-
(HOC) `withAppSearch`. This HOC simply exposes all state and actions as `props`.
174
+
(HOC) `withSearch`. This HOC simply exposes all state and actions as `props`.
175
175
A consuming Container simply accesses those actions and state, composes
176
176
appropriate handlers and data as props and passes them to the appropriate
177
177
Component.
@@ -195,18 +195,30 @@ It should be feasible to use this project as a starting point for your
195
195
own implementation. Here are a few places to look to make changes:
196
196
197
197
- The styles for the entire project can be found in [src/styles](src/styles).
198
-
Simple style tweaks changes can be made here, or you could replace these styles
199
-
with your own.
198
+
Simple style tweaks can be made here, or you could replace these styles
199
+
entirely with your own.
200
200
-[src/components](src/components) contains the view templates for
201
201
components. Structural HTML changes can be made here.
202
202
- If you find that you have different data or behavior requirements for
203
203
existing components, you can customize the component Containers in
204
204
[src/containers](src/containers).
205
205
- If you find you have requirements that none of the existing components
206
206
satisfy, you could create an entirely new component and/or container. Use the
207
-
`withAppSearch` HOC in order to access any action or state.
207
+
[withSearch.js](src/search-lib/withSearch.js) HOC in order to access any action or state.
208
+
- The SearchDriver can be configured directly in [App.js](src/App.js) to do things like:
209
+
210
+
- Optimize your API calls
211
+
- Add additional facets and customize facet behavior
212
+
- Disable URL State management
213
+
214
+
A full list of configuration options can be found in [SearchDriver.js](src/search-lib/SearchDriver.js)
215
+
216
+
- Eject from 'configuration'. You may choose to to delete the entire [src/config](src/config) directory, which holds the configuration logic that makes this a
217
+
generic UI. If you're using this as your own, production application, you likely
218
+
won't need this.
219
+
208
220
- Lastly, if you find there is a core action or state missing, you may
209
-
consider updating the core logic in [src/app-search](src/app-search).
221
+
consider updating the core logic in [src/search-lib](src/search-lib).
210
222
211
223
Lastly, we accept PRs! If you make a customization that you think would benefit
0 commit comments