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
+51-24Lines changed: 51 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,24 @@
1
-
jQuery Plugin for Swiftype Site Search
2
-
=========
1
+
<palign="center"><imgsrc="https://github.com/swiftype/swiftype-search-jquery/blob/master/logo-site-search.png?raw=true"alt="Elastic Site Search Logo"></p>
3
2
4
-
The official [Swiftype Site Search](http://www.swiftype.com/site-search) jQuery plugin for adding search functionality backed by data from the Swiftype Site Search API. Learn more about Swiftype by visiting [swiftype.com](http://www.swiftype.com) and creating an account.
3
+
> A first-party [Elastic Site Search](https://swiftype.com/documentation/site-search/overview) jQuery plugin for website search.
5
4
6
-
> **Note:** This client has been developed for the [Swiftype Site Search](https://www.swiftype.com/site-search) API endpoints only. You may refer to the [Swiftype Site Search API Documentation](https://swiftype.com/documentation/site-search/overview) for additional context.
5
+
## Contents
7
6
8
-
Prerequisites
9
-
------------
10
-
1. A Swiftype account. Sign up at [swiftype.com](http://www.swiftype.com).
11
-
2. A Swiftype Site Search engine with some data in it.
> **Note:** This client has been developed for the [Elastic Site Search](https://www.swiftype.com/site-search) API endpoints only. You may refer to the [Elastic Site Search API Documentation](https://swiftype.com/documentation/site-search/overview) for additional context.
33
40
34
-
Basic Usage
35
-
-----
41
+
42
+
## Usage
36
43
37
44
Start by having at least these three elements on the page: a form, an input field within the form, and a container for results.
38
45
@@ -43,7 +50,7 @@ Start by having at least these three elements on the page: a form, an input fiel
43
50
<divid="st-results-container"></div>
44
51
```
45
52
46
-
Simply apply the swiftype method to an existing search input field within a form on your webpage and provide a container for results. For example, add it to a search input field with id `st-search-input` as follows:
53
+
Apply the swiftype method to an existing search input field within a form on your webpage and provide a container for results. For example, add it to a search input field with id `st-search-input` as follows:
Be sure to change the `engineKey` attribute shown above to match the one assigned to your Swiftype search engine. If you are using the web interface, the search engine key is listed on the first page of your dashboard.
56
63
57
-
58
-
Customization Tutorial
59
-
-------------
64
+
## Customization tutorial
60
65
61
66
This plugin is written to be flexible based on your specific use-case.
62
67
For example you might want to retrieve more data for each result, customize
63
68
the way data is display to the user, or restrict the search query to certain elements of your search engine.
64
69
65
70
Let's go through an example that does all of this. For this example, let's assume you followed the QuickStart tutorial for our [Ruby Gem](https://github.com/swiftype/swiftype-rb), and now you have data for a Bookstore indexed in your example search engine.
66
71
67
-
####Changing the number of results per page
72
+
### Changing the number of results per page
68
73
69
74
To specify the number of results per page, use the `perPage` attribute.
70
75
@@ -96,7 +101,7 @@ The `highlightFields` option accepts a hash containing the fields you want to ha
96
101
97
102
See the [custom.html](https://github.com/swiftype/swiftype-search-jquery/blob/master/custom.html) file for an additional example of `highlightFields`.
98
103
99
-
####Fetching only the fields you specify
104
+
### Fetching only the fields you specify
100
105
101
106
To specify the fields you would like returned from the API, set the `fetchFields` attribute to a hash containing an array listing the fields you want returned for each document type. For example, if you have indexed `title`, `genre`, and `published_on` fields for each document, you can have them returned as follows:
By default, the Swiftype search library will match the submitted query to any `string` or `text` field indexed for your documents. So if you would like to ensure that it only matches entries in the `title` field, for example, you can specify the `searchFields` option:
Similarly to the `fetchFields` option, `searchFields` accepts a hash containing an array of fields for each document_type on which you would like the user's query to match.
157
162
158
-
####Specifying additional query conditions
163
+
### Specifying additional query conditions
159
164
160
165
Now let's say you only want your results to display books that are of the **fiction**`genre` and are **in_stock**. In order to restrict search results, you can pass additional query conditions to the search API by specifying them as a dictionary in the `filters` field. Multiple clauses in the filters field are combined with AND logic:
If something is not working as expected, please open an [issue](https://github.com/swiftype/swiftype-search-jquery/issues/new).
182
+
183
+
### Where can I learn more about Site Search?
184
+
185
+
Your best bet is to read the [documentation](https://swiftype.com/documentation/site-search).
186
+
187
+
### Where else can I go to get help?
188
+
189
+
You can checkout the [Elastic Site Search community discuss forums](https://discuss.elastic.co/c/site-search).
190
+
191
+
## Contribute 🚀
192
+
193
+
We welcome contributors to the project. Before you begin, a couple notes...
194
+
195
+
+ Before opening a pull request, please create an issue to [discuss the scope of your proposal](https://github.com/swiftype/swiftype-search-jquery/issues).
196
+
+ Please write simple code and concise documentation, when appropriate.
0 commit comments