├── .circleci
└── config.yml
├── .gitignore
├── .npmrc
├── .nvmrc
├── LICENSE.txt
├── NOTICE.txt
├── README.md
├── fixtures
└── api.swiftype.com-443
│ ├── 148029466371372802
│ ├── 148029466446915950
│ ├── 148029466530123763
│ ├── 148029466611691036
│ ├── 148029466708231500
│ ├── 148029466792351727
│ ├── 148029466873182317
│ ├── 148029466954567553
│ ├── 148029467029099955
│ ├── 148029467107375785
│ ├── 148029467186250208
│ ├── 148029467260453725
│ ├── 148029467344719036
│ ├── 148029467430131012
│ ├── 148029467517823740
│ ├── 148029467596089524
│ ├── 148029467680011529
│ ├── 148029467759877442
│ ├── 148029467837761609
│ ├── 148029467923258609
│ ├── 148029468003891985
│ ├── 148029468083835290
│ ├── 14802946816911076
│ ├── 148029468252730589
│ ├── 148029468345667253
│ ├── 148029468437989007
│ ├── 148029468517265436
│ ├── 148029468598263921
│ ├── 148029468707739911
│ ├── 148029468802698220
│ ├── 148029468887772266
│ ├── 148029468978144492
│ ├── 153791495181660002
│ └── 153791496615957117
├── lib
├── analytics.js
├── client.js
├── documentTypes.js
├── documents.js
├── engines.js
└── siteSearch.js
├── logo-site-search.png
├── package.json
└── test
├── analyticsTest.js
├── clientTest.js
├── documentTypesTest.js
├── documentsTest.js
├── enginesTest.js
└── siteSearchTest.js
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | # Javascript Node CircleCI 2.0 configuration file
2 | #
3 | # Check https://circleci.com/docs/2.0/language-javascript/ for more details
4 | #
5 | version: 2
6 | jobs:
7 | build:
8 | docker:
9 | # specify the version you desire here
10 | - image: circleci/node:8
11 |
12 | # Specify service dependencies here if necessary
13 | # CircleCI maintains a library of pre-built images
14 | # documented at https://circleci.com/docs/2.0/circleci-images/
15 | # - image: circleci/mongo:3.4.4
16 |
17 | working_directory: ~/repo
18 |
19 | steps:
20 | - checkout
21 |
22 | # Download and cache dependencies
23 | - restore_cache:
24 | keys:
25 | - v1-dependencies-{{ checksum "package.json" }}
26 | # fallback to using the latest cache if no exact match is found
27 | - v1-dependencies-
28 |
29 | - run: npm install
30 |
31 | - save_cache:
32 | paths:
33 | - node_modules
34 | key: v1-dependencies-{{ checksum "package.json" }}
35 |
36 | # run tests!
37 | - run: npm test
38 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | npm-debug.log
3 | package-lock.json
4 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
2 |
--------------------------------------------------------------------------------
/.nvmrc:
--------------------------------------------------------------------------------
1 | 8
2 |
3 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright 2019 Elasticsearch B.V.
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/NOTICE.txt:
--------------------------------------------------------------------------------
1 | Elastic Site Search Node client.
2 | Copyright 2012-2019 Elasticsearch B.V.
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |

2 |
3 | 
4 |
5 | > A first-party Node client for the [Elastic Site Search API](https://swiftype.com/documentation/site-search/overview).
6 |
7 | ## Contents
8 |
9 | - [Getting started](#getting-started-)
10 | - [Usage](#usage)
11 | - [Running tests](#running-tests)
12 | - [FAQ](#faq-)
13 | - [Contribute](#contribute-)
14 | - [License](#license-)
15 |
16 | ---
17 |
18 | ## Getting started 🐣
19 |
20 | With npm:
21 |
22 | ```shell
23 | npm install @elastic/site-search-node
24 | ```
25 |
26 | or clone locally:
27 |
28 | ```shell
29 | $ git clone git@github.com:elastic/site-search-node.git
30 | $ cd site-search-node
31 | $ npm install
32 | ```
33 |
34 | ## Usage
35 |
36 | Create a new instance of the client with your api key:
37 |
38 | ```javascript
39 | var SiteSearchClient = require("@elastic/site-search-node");
40 | var client = new SiteSearchClient({
41 | apiKey: "yourApiKey"
42 | });
43 | ```
44 |
45 | ### Searching
46 |
47 | Search for `cats` on the engine `my-engine` with filters and facets:
48 |
49 | ```javascript
50 | client.search(
51 | {
52 | engine: "my-engine",
53 | q: "cats",
54 | filters: {
55 | page: {
56 | enumField: "theFilter"
57 | }
58 | },
59 | facets: {
60 | page: ["enumField", "anotherField"]
61 | }
62 | },
63 | function(err, res) {
64 | console.log(res);
65 | }
66 | );
67 | ```
68 |
69 | ### Autocomplete
70 |
71 | Autocomplete suggestion for `cat` on the engine `my-engine` with filters:
72 |
73 | ```javascript
74 | client.suggest(
75 | {
76 | engine: "my-engine",
77 | q: "cat",
78 | filters: {
79 | page: {
80 | enumField: "theFilter"
81 | }
82 | }
83 | },
84 | function(err, res) {
85 | console.log(res);
86 | }
87 | );
88 | ```
89 |
90 | ### Click
91 |
92 | Log clickthrough for `cat` on the engine `my-engine` for the documentType `page`:
93 |
94 | ```javascript
95 | client.click(
96 | {
97 | engine: "my-engine",
98 | q: "cat",
99 | id: "the-document-id",
100 | documentType: "page"
101 | },
102 | function(err, res) {
103 | console.log(res);
104 | }
105 | );
106 | ```
107 |
108 | ### Documents
109 |
110 | Create a new document:
111 |
112 | ```javascript
113 | client.documents.create(
114 | {
115 | engine: "my-engine",
116 | documentType: "books",
117 | document: {
118 | external_id: "1",
119 | fields: [
120 | { name: "title", value: "The Great Gatsby", type: "string" },
121 | { name: "author", value: "F. Scott Fitzgerald", type: "string" },
122 | { name: "genre", value: "fiction", type: "enum" }
123 | ]
124 | }
125 | },
126 | function(err, res) {
127 | console.log(res);
128 | }
129 | );
130 | ```
131 |
132 | ### Engines
133 |
134 | Fetch all of your engines:
135 |
136 | ```javascript
137 | client.engines.list(function(err, res) {
138 | console.log(res);
139 | });
140 | ```
141 |
142 | Fetch a single engine:
143 |
144 | ```javascript
145 | client.engines.get(
146 | {
147 | engine: "my-engine"
148 | },
149 | function(err, res) {
150 | console.log(res);
151 | }
152 | );
153 | ```
154 |
155 | ### Document Types
156 |
157 | Fetch all of the document types in the engine `my-engine`
158 |
159 | ```javascript
160 | client.documentTypes.list(
161 | {
162 | engine: "my-engine"
163 | },
164 | function(err, res) {
165 | console.log(res);
166 | }
167 | );
168 | ```
169 |
170 | Fetch the document type `books` in the engine `my-engine`
171 |
172 | ```javascript
173 | client.documentTypes.get(
174 | {
175 | engine: "my-engine",
176 | documentType: "books"
177 | },
178 | function(err, res) {
179 | console.log(res);
180 | }
181 | );
182 | ```
183 |
184 | Create the document type `books` in the engine `my-engine`
185 |
186 | ```javascript
187 | client.documentTypes.create(
188 | {
189 | engine: "my-engine",
190 | document_type: { name: "books" }
191 | },
192 | function(err, res) {
193 | console.log(res);
194 | }
195 | );
196 | ```
197 |
198 | Check out the tests for more examples!
199 |
200 | ## Running tests
201 |
202 | ```shell
203 | $ npm test
204 | ```
205 |
206 | The tests use stubbed HTTP interactions that are recorded with the [node-replay](https://github.com/assaf/node-replay) module. By default, HTTP interactions are not allowed when running the tests.
207 |
208 | The tests can also use environment variables so that you can create new replays against your own account. Don't forget to change the "authorization" header in the replay files to not give away your api key.
209 |
210 | - SITE_SEARCH_TEST_MY_ENGINE = the slug for your 'my-engine' in the tests
211 | - SITE_SEARCH_TEST_BOOKSTORE_ENGINE = the slug for your 'bookstore' in the tests
212 | - SITE_SEARCH_TEST_TEMPORARY_ENGINE = the slug for your 'temporary' in the tests
213 | - SITE_SEARCH_TEST_API_KEY = your api key in the tests
214 | - REPLAY = 'record' to record new replay files
215 |
216 | ## FAQ 🔮
217 |
218 | ### Where do I report issues with the client?
219 |
220 | If something is not working as expected, please open an [issue](https://github.com/elastic/site-search-node/issues/new).
221 |
222 | ### Where can I learn more about Site Search?
223 |
224 | Your best bet is to read the [documentation](https://swiftype.com/documentation/site-search).
225 |
226 | ### Where else can I go to get help?
227 |
228 | You can checkout the [Elastic Site Search community discuss forums](https://discuss.elastic.co/c/site-search).
229 |
230 | ## Contribute 🚀
231 |
232 | We welcome contributors to the project. Before you begin, a couple notes...
233 |
234 | - Before opening a pull request, please create an issue to [discuss the scope of your proposal](https://github.com/elastic/site-search-node/issues).
235 | - Please write simple code and concise documentation, when appropriate.
236 |
237 | ## License 📗
238 |
239 | [Apache 2.0](https://github.com/elastic/site-search-node/blob/master/LICENSE.txt) © [Elastic](https://github.com/elastic)
240 |
241 | Thank you to all the [contributors](https://github.com/elastic/site-search-node/graphs/contributors)!
242 |
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029466371372802:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/analytics/searches.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:43 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"0373916b7349d17758e89a3bb6245a10"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 2a99abef-a869-4d71-940e-9a3cd1448ab0
19 | x-runtime: 0.027572
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [["2016-11-28",0],["2016-11-27",0],["2016-11-26",0],["2016-11-25",0],["2016-11-24",0],["2016-11-23",0],["2016-11-22",0],["2016-11-21",0],["2016-11-20",0],["2016-11-19",0],["2016-11-18",0],["2016-11-17",0],["2016-11-16",0],["2016-11-15",0],["2016-11-14",0]]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029466446915950:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/analytics/searches.json?start_date=2014-06-12&end_date=2014-06-18
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:44 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"53826c1fb9363555f18c5efbd008f3ad"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: c28c2179-e08e-472c-90d4-855e195780cc
19 | x-runtime: 0.033111
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [["2014-06-18",0],["2014-06-17",0],["2014-06-16",0],["2014-06-15",0],["2014-06-14",0],["2014-06-13",0],["2014-06-12",0]]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029466530123763:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/document_types/videos/analytics/searches.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:45 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"0373916b7349d17758e89a3bb6245a10"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 807963f6-c8a3-497b-9931-a76749f93b7b
19 | x-runtime: 0.123596
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [["2016-11-28",0],["2016-11-27",0],["2016-11-26",0],["2016-11-25",0],["2016-11-24",0],["2016-11-23",0],["2016-11-22",0],["2016-11-21",0],["2016-11-20",0],["2016-11-19",0],["2016-11-18",0],["2016-11-17",0],["2016-11-16",0],["2016-11-15",0],["2016-11-14",0]]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029466611691036:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/document_types/videos/analytics/searches.json?start_date=2014-06-12&end_date=2014-06-18
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:46 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"53826c1fb9363555f18c5efbd008f3ad"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 5d77c85b-e42e-438b-a23e-63f039d7258e
19 | x-runtime: 0.065801
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [["2014-06-18",0],["2014-06-17",0],["2014-06-16",0],["2014-06-15",0],["2014-06-14",0],["2014-06-13",0],["2014-06-12",0]]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029466708231500:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/analytics/autoselects.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:46 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"0373916b7349d17758e89a3bb6245a10"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 3011dd50-58b1-4f87-bf6a-a858db3425fc
19 | x-runtime: 0.033423
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [["2016-11-28",0],["2016-11-27",0],["2016-11-26",0],["2016-11-25",0],["2016-11-24",0],["2016-11-23",0],["2016-11-22",0],["2016-11-21",0],["2016-11-20",0],["2016-11-19",0],["2016-11-18",0],["2016-11-17",0],["2016-11-16",0],["2016-11-15",0],["2016-11-14",0]]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029466792351727:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/analytics/autoselects.json?start_date=2014-06-12&end_date=2014-06-18
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:47 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"53826c1fb9363555f18c5efbd008f3ad"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 2e03324a-a58f-4f53-a133-6c1330137baf
19 | x-runtime: 0.034366
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [["2014-06-18",0],["2014-06-17",0],["2014-06-16",0],["2014-06-15",0],["2014-06-14",0],["2014-06-13",0],["2014-06-12",0]]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029466873182317:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/document_types/videos/analytics/autoselects.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:48 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"0373916b7349d17758e89a3bb6245a10"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 8316191f-a52c-456c-a274-d7bb1d331493
19 | x-runtime: 0.059728
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [["2016-11-28",0],["2016-11-27",0],["2016-11-26",0],["2016-11-25",0],["2016-11-24",0],["2016-11-23",0],["2016-11-22",0],["2016-11-21",0],["2016-11-20",0],["2016-11-19",0],["2016-11-18",0],["2016-11-17",0],["2016-11-16",0],["2016-11-15",0],["2016-11-14",0]]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029466954567553:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/document_types/videos/analytics/autoselects.json?start_date=2014-06-12&end_date=2014-06-18
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:49 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"53826c1fb9363555f18c5efbd008f3ad"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 744d09ec-384d-4a55-8ace-cc1d399b17fc
19 | x-runtime: 0.035857
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [["2014-06-18",0],["2014-06-17",0],["2014-06-16",0],["2014-06-15",0],["2014-06-14",0],["2014-06-13",0],["2014-06-12",0]]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029467029099955:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/analytics/clicks.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:50 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"0373916b7349d17758e89a3bb6245a10"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 3380042f-49c0-4620-9081-c7e81893f979
19 | x-runtime: 0.035476
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [["2016-11-28",0],["2016-11-27",0],["2016-11-26",0],["2016-11-25",0],["2016-11-24",0],["2016-11-23",0],["2016-11-22",0],["2016-11-21",0],["2016-11-20",0],["2016-11-19",0],["2016-11-18",0],["2016-11-17",0],["2016-11-16",0],["2016-11-15",0],["2016-11-14",0]]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029467107375785:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/analytics/clicks.json?start_date=2014-06-12&end_date=2014-06-18
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:51 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"53826c1fb9363555f18c5efbd008f3ad"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 9cefea73-1206-4cbf-8cc6-e2cc77a29e8d
19 | x-runtime: 0.033187
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [["2014-06-18",0],["2014-06-17",0],["2014-06-16",0],["2014-06-15",0],["2014-06-14",0],["2014-06-13",0],["2014-06-12",0]]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029467186250208:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/document_types/videos/analytics/clicks.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:51 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"0373916b7349d17758e89a3bb6245a10"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: b73e5d03-7713-4275-bbd4-bb03eecd444c
19 | x-runtime: 0.040205
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [["2016-11-28",0],["2016-11-27",0],["2016-11-26",0],["2016-11-25",0],["2016-11-24",0],["2016-11-23",0],["2016-11-22",0],["2016-11-21",0],["2016-11-20",0],["2016-11-19",0],["2016-11-18",0],["2016-11-17",0],["2016-11-16",0],["2016-11-15",0],["2016-11-14",0]]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029467260453725:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/document_types/videos/analytics/clicks.json?start_date=2014-06-12&end_date=2014-06-18
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:52 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"53826c1fb9363555f18c5efbd008f3ad"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 709c0309-d4f0-4994-9a63-48011dd7bda9
19 | x-runtime: 0.030616
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [["2014-06-18",0],["2014-06-17",0],["2014-06-16",0],["2014-06-15",0],["2014-06-14",0],["2014-06-13",0],["2014-06-12",0]]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029467344719036:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/analytics/top_queries.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:53 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"d751713988987e9331980363e24189ce"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 72cd7227-3042-4f4b-b59d-c19d9a8dbc16
19 | x-runtime: 0.059902
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | []
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029467430131012:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/analytics/top_no_result_queries.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:54 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"d751713988987e9331980363e24189ce"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: bbf6513f-1274-4158-a571-5ea30da60d13
19 | x-runtime: 0.073482
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | []
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029467517823740:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/document_types.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:55 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"4563ae003805ba30a7fcf40d9e5de5c3"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 176dbdeb-7916-42f7-a720-47f4867adf61
19 | x-runtime: 0.079409
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [{"id":"583b80b2aadf4f60669a4c27","name":"books","slug":"books","engine_id":"583b80b2aadf4f60669a4c28","updated_at":"2016-11-28T00:56:19Z","document_count":0,"field_mapping":{}},{"id":"583b80b2aadf4f60669a4c29","name":"videos","slug":"videos","engine_id":"583b80b2aadf4f60669a4c28","updated_at":"2016-11-28T00:56:19Z","document_count":0,"field_mapping":{}}]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029467596089524:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/document_types/books.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:55 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"6d72a2ec10649ae4b3ce84852230db5c"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 754d1d75-95e5-49af-b335-9d67c4f9f876
19 | x-runtime: 0.060060
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | {"id":"583b80b2aadf4f60669a4c27","name":"books","slug":"books","engine_id":"583b80b2aadf4f60669a4c28","updated_at":"2016-11-28T00:56:19Z","document_count":0,"field_mapping":{}}
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029467680011529:
--------------------------------------------------------------------------------
1 | POST /api/v1/engines/bookstore/document_types.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 | accept: application/json
5 | content-type: application/json
6 | body: {\"document_type\":{\"name\":\"magazines\"}}
7 |
8 | HTTP/1.1 200 OK
9 | server: openresty/1.7.10.2
10 | date: Mon, 28 Nov 2016 00:57:56 GMT
11 | content-type: application/json; charset=utf-8
12 | transfer-encoding: chunked
13 | connection: close
14 | vary: Accept-Encoding, Accept-Encoding
15 | status: 200 OK
16 | x-frame-options: SAMEORIGIN
17 | x-xss-protection: 1; mode=block
18 | x-content-type-options: nosniff
19 | etag: W/"3c58c4ace1ccd237956484eddb905a8f"
20 | cache-control: max-age=0, private, must-revalidate
21 | x-request-id: 3eb96e78-a876-457e-bb8e-f00ba13f5ef2
22 | x-runtime: 0.131302
23 | x-swiftype-datacenter: dal05
24 | x-swiftype-frontend-node: web01.dal05
25 | x-swiftype-edge-node: web01.dal05
26 |
27 | {"id":"583b8114d3b6871d7d4ac4c2","name":"magazines","slug":"magazines","engine_id":"583b80b2aadf4f60669a4c28","updated_at":"2016-11-28T00:57:56Z","document_count":0,"field_mapping":{}}
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029467759877442:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/document_types/books/search.json?q=Gatsby
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:57:57 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"5c5e47e10c35ec6fc9a7a6406476e4b0"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: a0489ea5-8a08-4c48-8f5f-81406d7180d1
19 | x-runtime: 0.097066
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | {"records":{"books":[]},"info":{"books":{"query":"Gatsby","current_page":1,"num_pages":1,"per_page":10,"total_result_count":0,"facets":{}}},"record_count":0,"errors":{}}
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029467837761609:
--------------------------------------------------------------------------------
1 | DELETE /api/v1/engines/bookstore/document_types/magazines
2 | accept: */*
3 | host: api.swiftype.com
4 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
5 |
6 | HTTP/1.1 204 No Content
7 | server: openresty/1.7.10.2
8 | date: Mon, 28 Nov 2016 00:57:58 GMT
9 | connection: close
10 | status: 204 No Content
11 | x-frame-options: SAMEORIGIN
12 | x-xss-protection: 1; mode=block
13 | x-content-type-options: nosniff
14 | cache-control: no-cache
15 | x-request-id: b1fa0b99-f858-4c6d-8a35-eab24a9d646b
16 | x-runtime: 0.092748
17 | x-swiftype-datacenter: dal05
18 | x-swiftype-frontend-node: web01.dal05
19 | x-swiftype-edge-node: web01.dal05
20 |
21 |
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029467923258609:
--------------------------------------------------------------------------------
1 | POST /api/v1/engines/bookstore/document_types/books/documents/create_or_update.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 | accept: application/json
5 | content-type: application/json
6 | body: {\"document\":{\"external_id\":\"1\",\"fields\":[{\"name\":\"title\",\"value\":\"The Great Gatsby\",\"type\":\"string\"},{\"name\":\"author\",\"value\":\"F. Scott Fitzgerald\",\"type\":\"string\"},{\"name\":\"genre\",\"value\":\"fiction\",\"type\":\"enum\"}]}}
7 |
8 | HTTP/1.1 200 OK
9 | server: openresty/1.7.10.2
10 | date: Mon, 28 Nov 2016 00:57:59 GMT
11 | content-type: application/json; charset=utf-8
12 | transfer-encoding: chunked
13 | connection: close
14 | vary: Accept-Encoding, Accept-Encoding
15 | status: 200 OK
16 | x-frame-options: SAMEORIGIN
17 | x-xss-protection: 1; mode=block
18 | x-content-type-options: nosniff
19 | etag: W/"e6b001415bec96e85f8a1a0c635ee478"
20 | cache-control: max-age=0, private, must-revalidate
21 | x-request-id: d6ab82eb-b306-4b94-b873-18b0dd34a2d6
22 | x-runtime: 0.108401
23 | x-swiftype-datacenter: dal05
24 | x-swiftype-frontend-node: web01.dal05
25 | x-swiftype-edge-node: web01.dal05
26 |
27 | {"external_id":"1","engine_id":"583b80b2aadf4f60669a4c28","document_type_id":"583b80b2aadf4f60669a4c27","id":"583b8117d3b687025e4ac261","updated_at":"2016-11-28T00:57:59+00:00","title":"The Great Gatsby","author":"F. Scott Fitzgerald","genre":"fiction"}
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029468003891985:
--------------------------------------------------------------------------------
1 | POST /api/v1/engines/bookstore/document_types/books/documents/bulk_create_or_update.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 | accept: application/json
5 | content-type: application/json
6 | body: {\"documents\":[{\"external_id\":\"3\",\"fields\":[{\"name\":\"title\",\"value\":\"A Great Book\",\"type\":\"string\"}]},{\"external_id\":\"4\",\"fields\":[{\"name\":\"title\",\"value\":\"Another Great Book\",\"type\":\"string\"}]}]}
7 |
8 | HTTP/1.1 200 OK
9 | server: openresty/1.7.10.2
10 | date: Mon, 28 Nov 2016 00:58:00 GMT
11 | content-type: application/json; charset=utf-8
12 | transfer-encoding: chunked
13 | connection: close
14 | vary: Accept-Encoding, Accept-Encoding
15 | status: 200 OK
16 | x-frame-options: SAMEORIGIN
17 | x-xss-protection: 1; mode=block
18 | x-content-type-options: nosniff
19 | etag: W/"bb009c6dcb5c622766ad5aa1ea1562d9"
20 | cache-control: max-age=0, private, must-revalidate
21 | x-request-id: 5313a2db-5395-4cac-9641-9d788a556086
22 | x-runtime: 0.113101
23 | x-swiftype-datacenter: dal05
24 | x-swiftype-frontend-node: web01.dal05
25 | x-swiftype-edge-node: web01.dal05
26 |
27 | [true,true]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029468083835290:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/document_types/books/documents/1.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:58:00 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"e6b001415bec96e85f8a1a0c635ee478"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: b5045a4e-3557-4cc0-9e02-e2a1261f1db7
19 | x-runtime: 0.113232
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | {"external_id":"1","engine_id":"583b80b2aadf4f60669a4c28","document_type_id":"583b80b2aadf4f60669a4c27","id":"583b8117d3b687025e4ac261","updated_at":"2016-11-28T00:57:59+00:00","title":"The Great Gatsby","author":"F. Scott Fitzgerald","genre":"fiction"}
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/14802946816911076:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/bookstore/document_types/books/documents.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:58:01 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"4d3c4a91a74809a7e62a053c6e60603c"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 9a43e0b7-cb27-4ecd-9c4e-9b63e458306d
19 | x-runtime: 0.054918
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [{"external_id":"3","engine_id":"583b80b2aadf4f60669a4c28","document_type_id":"583b80b2aadf4f60669a4c27","id":"583b811714cc8a0d6f2f942c","updated_at":"2016-11-28T00:57:59+00:00","title":"A Great Book"},{"external_id":"4","engine_id":"583b80b2aadf4f60669a4c28","document_type_id":"583b80b2aadf4f60669a4c27","id":"583b811714cc8a0d6f2f942d","updated_at":"2016-11-28T00:57:59+00:00","title":"Another Great Book"},{"external_id":"1","engine_id":"583b80b2aadf4f60669a4c28","document_type_id":"583b80b2aadf4f60669a4c27","id":"583b8117d3b687025e4ac261","updated_at":"2016-11-28T00:57:59+00:00","title":"The Great Gatsby","author":"F. Scott Fitzgerald","genre":"fiction"}]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029468252730589:
--------------------------------------------------------------------------------
1 | PUT /api/v1/engines/bookstore/document_types/books/documents/1/update_fields.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 | accept: application/json
5 | content-type: application/json
6 | body: {\"fields\":{\"title\":\"This Side of Paradise\"}}
7 |
8 | HTTP/1.1 200 OK
9 | server: openresty/1.7.10.2
10 | date: Mon, 28 Nov 2016 00:58:02 GMT
11 | content-type: application/json; charset=utf-8
12 | transfer-encoding: chunked
13 | connection: close
14 | vary: Accept-Encoding, Accept-Encoding
15 | status: 200 OK
16 | x-frame-options: SAMEORIGIN
17 | x-xss-protection: 1; mode=block
18 | x-content-type-options: nosniff
19 | etag: W/"a7c3759096591cd3fcdee601f3ef141c"
20 | cache-control: max-age=0, private, must-revalidate
21 | x-request-id: 2a57686f-b669-401b-a7d4-671e6b99bd8b
22 | x-runtime: 0.094714
23 | x-swiftype-datacenter: dal05
24 | x-swiftype-frontend-node: web01.dal05
25 | x-swiftype-edge-node: web01.dal05
26 |
27 | {"external_id":"1","engine_id":"583b80b2aadf4f60669a4c28","document_type_id":"583b80b2aadf4f60669a4c27","id":"583b8117d3b687025e4ac261","updated_at":"2016-11-28T00:58:02+00:00","title":"This Side of Paradise","author":"F. Scott Fitzgerald","genre":"fiction"}
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029468345667253:
--------------------------------------------------------------------------------
1 | DELETE /api/v1/engines/bookstore/document_types/books/documents/1
2 | accept: */*
3 | host: api.swiftype.com
4 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
5 |
6 | HTTP/1.1 204 No Content
7 | server: openresty/1.7.10.2
8 | date: Mon, 28 Nov 2016 00:58:03 GMT
9 | connection: close
10 | status: 204 No Content
11 | x-frame-options: SAMEORIGIN
12 | x-xss-protection: 1; mode=block
13 | x-content-type-options: nosniff
14 | cache-control: no-cache
15 | x-request-id: d2dcf53a-347f-45ef-be64-e60a53ae2216
16 | x-runtime: 0.147702
17 | x-swiftype-datacenter: dal05
18 | x-swiftype-frontend-node: web01.dal05
19 | x-swiftype-edge-node: web01.dal05
20 |
21 |
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029468437989007:
--------------------------------------------------------------------------------
1 | POST /api/v1/engines/bookstore/document_types/books/documents/bulk_destroy.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 | accept: application/json
5 | content-type: application/json
6 | body: {\"documents\":[\"3\",\"4\"]}
7 |
8 | HTTP/1.1 200 OK
9 | server: openresty/1.7.10.2
10 | date: Mon, 28 Nov 2016 00:58:04 GMT
11 | content-type: application/json; charset=utf-8
12 | transfer-encoding: chunked
13 | connection: close
14 | vary: Accept-Encoding, Accept-Encoding
15 | status: 200 OK
16 | x-frame-options: SAMEORIGIN
17 | x-xss-protection: 1; mode=block
18 | x-content-type-options: nosniff
19 | etag: W/"bb009c6dcb5c622766ad5aa1ea1562d9"
20 | cache-control: max-age=0, private, must-revalidate
21 | x-request-id: a4f5b4e8-eb83-475a-911f-269da27bb617
22 | x-runtime: 0.170880
23 | x-swiftype-datacenter: dal05
24 | x-swiftype-frontend-node: web01.dal05
25 | x-swiftype-edge-node: web01.dal05
26 |
27 | [true,true]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029468517265436:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:58:05 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"73e55a610841323f7c227171aba2132a"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: cf7f73fb-a66c-441b-a23c-8c98e152eb18
19 | x-runtime: 0.031512
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | [{"name":"My Engine","slug":"my-engine","key":"xABi1sEPhxSiSEYQde4K","id":"583a09fbf884487b1860c64c","_id":"583a09fbf884487b1860c64c","updated_at":"2016-11-26T22:22:49Z","document_count":195},{"name":"Bookstore","slug":"bookstore","key":"xJ-i_9yJ8HRJMshU_KTx","id":"583b80b2aadf4f60669a4c28","_id":"583b80b2aadf4f60669a4c28","updated_at":"2016-11-28T00:56:19Z","document_count":0}]
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029468598263921:
--------------------------------------------------------------------------------
1 | GET /api/v1/engines/my-engine.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 |
5 | HTTP/1.1 200 OK
6 | server: openresty/1.7.10.2
7 | date: Mon, 28 Nov 2016 00:58:05 GMT
8 | content-type: application/json; charset=utf-8
9 | transfer-encoding: chunked
10 | connection: close
11 | vary: Accept-Encoding, Accept-Encoding
12 | status: 200 OK
13 | x-frame-options: SAMEORIGIN
14 | x-xss-protection: 1; mode=block
15 | x-content-type-options: nosniff
16 | etag: W/"20cd3b07f0d3fe9cecf690bc93a9f9e8"
17 | cache-control: max-age=0, private, must-revalidate
18 | x-request-id: 49d10122-73e8-4a34-b0e9-c368985baf40
19 | x-runtime: 0.055499
20 | x-swiftype-datacenter: dal05
21 | x-swiftype-frontend-node: web01.dal05
22 | x-swiftype-edge-node: web01.dal05
23 |
24 | {"name":"My Engine","slug":"my-engine","key":"xABi1sEPhxSiSEYQde4K","id":"583a09fbf884487b1860c64c","_id":"583a09fbf884487b1860c64c","updated_at":"2016-11-26T22:22:49Z","document_count":195}
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029468707739911:
--------------------------------------------------------------------------------
1 | POST /api/v1/engines.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 | accept: application/json
5 | content-type: application/json
6 | body: {\"engine\":{\"name\":\"temporary\"}}
7 |
8 | HTTP/1.1 200 OK
9 | server: openresty/1.7.10.2
10 | date: Mon, 28 Nov 2016 00:58:07 GMT
11 | content-type: application/json; charset=utf-8
12 | transfer-encoding: chunked
13 | connection: close
14 | vary: Accept-Encoding, Accept-Encoding
15 | status: 200 OK
16 | x-frame-options: SAMEORIGIN
17 | x-xss-protection: 1; mode=block
18 | x-content-type-options: nosniff
19 | etag: W/"7c14425b3cfd5553ad0372659aade420"
20 | cache-control: max-age=0, private, must-revalidate
21 | x-request-id: bbfb7ad7-1462-4734-9b0b-b4bfae7feb6f
22 | x-runtime: 0.365239
23 | x-swiftype-datacenter: dal05
24 | x-swiftype-frontend-node: web01.dal05
25 | x-swiftype-edge-node: web01.dal05
26 |
27 | {"name":"temporary","slug":"temporary","key":"2aa2dCo3nxhxy8XAwU2d","id":"583b811ea1f2530340695ee8","_id":"583b811ea1f2530340695ee8","updated_at":"2016-11-28T00:58:06Z","document_count":0}
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029468802698220:
--------------------------------------------------------------------------------
1 | DELETE /api/v1/engines/temporary
2 | accept: */*
3 | host: api.swiftype.com
4 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
5 |
6 | HTTP/1.1 204 No Content
7 | server: openresty/1.7.10.2
8 | date: Mon, 28 Nov 2016 00:58:07 GMT
9 | connection: close
10 | status: 204 No Content
11 | x-frame-options: SAMEORIGIN
12 | x-xss-protection: 1; mode=block
13 | x-content-type-options: nosniff
14 | cache-control: no-cache
15 | x-request-id: fb9ba188-4e1a-49dc-852e-aad9dfd9fb0f
16 | x-runtime: 0.242765
17 | x-swiftype-datacenter: dal05
18 | x-swiftype-frontend-node: web01.dal05
19 | x-swiftype-edge-node: web01.dal05
20 |
21 |
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029468887772266:
--------------------------------------------------------------------------------
1 | POST /api/v1/engines/my-engine/search.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 | accept: application/json
5 | content-type: application/json
6 | body: {\"q\":\"awesome\"}
7 |
8 | HTTP/1.1 200 OK
9 | server: openresty/1.7.10.2
10 | date: Mon, 28 Nov 2016 00:58:08 GMT
11 | content-type: application/json; charset=utf-8
12 | transfer-encoding: chunked
13 | connection: close
14 | vary: Accept-Encoding, Accept-Encoding
15 | status: 200 OK
16 | x-frame-options: SAMEORIGIN
17 | x-xss-protection: 1; mode=block
18 | x-content-type-options: nosniff
19 | etag: W/"f48e60320b3995cf92f3d91f113a1acf"
20 | cache-control: max-age=0, private, must-revalidate
21 | x-request-id: cbcfce40-0875-4447-abe6-d0e97da8ecc4
22 | x-runtime: 0.156267
23 | x-swiftype-datacenter: dal05
24 | x-swiftype-frontend-node: web01.dal05
25 | x-swiftype-edge-node: web01.dal05
26 |
27 | {"record_count":1,"records":{"page":[{"body":"Swiftype forAsana We\u2019ve found Swiftype to be a goldmine of analytics data\u2014seeing what people are searching for, finding, and not finding. We share these reports with the product team to illuminate user confusion and pain points, and we use the data to add support content and make product changes. \u2014 Asana marketing team Watch the testimonial About Asana Asana is a website and mobile app that helps teams collaborate by putting conversations and tasks together in one place, allowing users to get more done with less effort. Search for Swiftype powers search for the Asana Guide\u2014a comprehensive support portal that helps Asana users get the most out of the product. Why Swiftype? They needed strong search and in-depth analytics on customer behavior. Knowledge Base Search by\u00a0Swiftype Increase case-deflection and decrease your support burden with better search. Learn more Awesome guide, disappointing search From the start, Asana prided itself on high-quality customer service, but they wanted to find a way to scale without hiring a massive support team. To make this possible, Asana created an extremely detailed product guide and documentation center\u2014but users were having a hard time searching through all of its content. Empowering users After implementing Swiftype, Asana users were able to find their answers faster, which empowered users to educate themselves about the product and, according to Ryan Pittington, User Operations Lead, made it a \u201cbetter experience to use the Guide than to contact support.\u201d Identifying blind spots Ryan uses Swiftype analytics to make sure that users never run into dead ends on their support page. By checking his Swiftype dashboard, Ryan can see the top queries that return no results, prompting him to create content for those user issues or customize search results for those queries through the drag-and-drop results reordering interface\u2014a feature he described as \u201clike magic to me.\u201d Additionally, Asana has gained unexpected intel on their users by looking closely at their top queries, unearthing new ways that customers use their product. Accessible for all users In contrast to his experience with Google Analytics, Ryan found the Swiftype dashboard highly accessible and user-friendly\u2014so much so that many members of the operations team receive the weekly search analytics emails. These dashboard analytics and weekly emails serve as a constant reminder of the precise needs of Asana\u2019s users, allowing the team to continually expand their support content and efficiently resolve user issues. Similar stories and\u00a0more SurveyMonkey came to Swiftype for fast, customizable search across their multi-language self-service help center. Read the Case Study Shopify needed a powerful search engine to help their users dig through their extensive documentation easily. Read the Case Study","external_id":"721bb7d56da350c8b5947d4800e54298304352d9","sections":["Swiftype forAsana","Awesome guide, disappointing search","Empowering users","Identifying blind spots","Accessible for all users","Similar stories and\u00a0more"],"title":"Asana Case Study | Swiftype","updated_at":"2016-11-26T22:20:55Z","image":"https://ma.swiftypecdn.com/assets/new_marketing/views/customers/screenshots/asana-83641a1636e0bbde0b729d8899e0b58d.jpg","type":"","url":"https://swiftype.com/customers/knowledge-base-search-asana","popularity":1,"published_at":"2016-11-27T00:12:36Z","info":"","_index":"crawled","_type":"page","_score":0.93117666,"_version":null,"_explanation":null,"sort":null,"highlight":{"sections":"Awesome guide, disappointing search","body":"analytics on customer behavior. Knowledge Base Search by\u00a0Swiftype Increase case-deflection and decrease your support burden with better search. Learn more Awesome guide, disappointing search From the start, Asana prided itself on high-quality customer service, but they wanted to find a way to scale without hiring"},"id":"583a0ac78e9c0f480fca73cb"}]},"info":{"page":{"query":"awesome","current_page":1,"num_pages":1,"per_page":20,"total_result_count":1,"facets":{}}},"errors":{}}
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/148029468978144492:
--------------------------------------------------------------------------------
1 | POST /api/v1/engines/my-engine/suggest.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 | accept: application/json
5 | content-type: application/json
6 | body: {\"q\":\"awe\"}
7 |
8 | HTTP/1.1 200 OK
9 | server: openresty/1.7.10.2
10 | date: Mon, 28 Nov 2016 00:58:09 GMT
11 | content-type: application/json; charset=utf-8
12 | transfer-encoding: chunked
13 | connection: close
14 | vary: Accept-Encoding, Accept-Encoding
15 | status: 200 OK
16 | x-frame-options: SAMEORIGIN
17 | x-xss-protection: 1; mode=block
18 | x-content-type-options: nosniff
19 | etag: W/"33354aaf6a33ea71e24c1265f3f43aa4"
20 | cache-control: max-age=0, private, must-revalidate
21 | x-request-id: ed35fd39-eacd-4d46-a422-659f2f56f3d9
22 | x-runtime: 0.154746
23 | x-swiftype-datacenter: dal05
24 | x-swiftype-frontend-node: web01.dal05
25 | x-swiftype-edge-node: web01.dal05
26 |
27 | {"record_count":1,"records":{"page":[{"external_id":"721bb7d56da350c8b5947d4800e54298304352d9","sections":["Swiftype forAsana","Awesome guide, disappointing search","Empowering users","Identifying blind spots","Accessible for all users","Similar stories and\u00a0more"],"title":"Asana Case Study | Swiftype","updated_at":"2016-11-26T22:20:55Z","image":"https://ma.swiftypecdn.com/assets/new_marketing/views/customers/screenshots/asana-83641a1636e0bbde0b729d8899e0b58d.jpg","type":"","url":"https://swiftype.com/customers/knowledge-base-search-asana","popularity":1,"published_at":"2016-11-27T00:12:36Z","info":"","_index":"crawled","_type":"page","_score":0.023670841,"_version":null,"_explanation":null,"sort":null,"highlight":{"sections":"Awesome guide, disappointing search"},"id":"583a0ac78e9c0f480fca73cb"}]},"info":{"page":{"query":"awe","current_page":1,"num_pages":1,"per_page":10,"total_result_count":1}},"errors":{}}
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/153791495181660002:
--------------------------------------------------------------------------------
1 | POST /api/v1/engines/my-engine/document_types/page/analytics/log_clickthrough.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 | accept: application/json
5 | content-type: application/json
6 | body: {\"q\":\"awesome\",\"id\":\"5b886b63827a6656794c6eaf\"}
7 |
8 | HTTP/1.1 200 OK
9 | date: Tue, 25 Sep 2018 22:35:51 GMT
10 | content-type: application/json
11 | transfer-encoding: chunked
12 | connection: close
13 | vary: Accept-Encoding, Accept-Encoding
14 | status: 200 OK
15 | x-frame-options: SAMEORIGIN
16 | x-xss-protection: 1; mode=block
17 | x-content-type-options: nosniff
18 | cache-control: no-cache
19 | x-request-id: fc5f6840fc6df7a787365fb12076b28f
20 | x-runtime: 0.072524
21 | x-swiftype-frontend-datacenter: dal05
22 | x-swiftype-frontend-node: web01.dal05
23 | x-swiftype-edge-datacenter: dal05
24 | x-swiftype-edge-node: web01.dal05
25 |
26 |
--------------------------------------------------------------------------------
/fixtures/api.swiftype.com-443/153791496615957117:
--------------------------------------------------------------------------------
1 | POST /api/v1/engines/my-engine/document_types/page/analytics/log_clickthrough.json
2 | host: api.swiftype.com
3 | authorization: Basic YS10ZXN0LWFwaS1rZXk6
4 | accept: application/json
5 | content-type: application/json
6 | body: {\"q\":\"awesome\",\"id\":\"5b886b63827a6656794c6eaf\"}
7 |
8 | HTTP/1.1 200 OK
9 | date: Tue, 25 Sep 2018 22:36:06 GMT
10 | content-type: application/json
11 | transfer-encoding: chunked
12 | connection: close
13 | vary: Accept-Encoding, Accept-Encoding
14 | status: 200 OK
15 | x-frame-options: SAMEORIGIN
16 | x-xss-protection: 1; mode=block
17 | x-content-type-options: nosniff
18 | cache-control: no-cache
19 | x-request-id: cef0150bad89625d658ddde6d823a74b
20 | x-runtime: 0.125830
21 | x-swiftype-frontend-datacenter: dal05
22 | x-swiftype-frontend-node: web01.dal05
23 | x-swiftype-edge-datacenter: dal05
24 | x-swiftype-edge-node: web01.dal05
25 |
26 |
--------------------------------------------------------------------------------
/lib/analytics.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Analytics = function(client) {
4 | this.client = client
5 | }
6 |
7 | Analytics.prototype = {
8 |
9 | searches: function(params, callback) {
10 | if (params.documentType) {
11 | this.client.get('/engines/{engine}/document_types/{documentType}/analytics/searches.json', params, callback)
12 | } else {
13 | this.client.get('/engines/{engine}/analytics/searches.json', params, callback)
14 | }
15 | },
16 |
17 | autoselects: function(params, callback) {
18 | if (params.documentType) {
19 | this.client.get('/engines/{engine}/document_types/{documentType}/analytics/autoselects.json', params, callback)
20 | } else {
21 | this.client.get('/engines/{engine}/analytics/autoselects.json', params, callback)
22 | }
23 | },
24 |
25 | clicks: function(params, callback) {
26 | if (params.documentType) {
27 | this.client.get('/engines/{engine}/document_types/{documentType}/analytics/clicks.json', params, callback)
28 | } else {
29 | this.client.get('/engines/{engine}/analytics/clicks.json', params, callback)
30 | }
31 | },
32 |
33 | topQueries: function(params, callback) {
34 | this.client.get('/engines/{engine}/analytics/top_queries.json', params, callback)
35 | },
36 |
37 | topNoResultQueries: function(params, callback) {
38 | this.client.get('/engines/{engine}/analytics/top_no_result_queries.json', params, callback)
39 | },
40 |
41 | logClickthrough: function(params, callback) {
42 | this.client.post('/engines/{engine}/document_types/{documentType}/analytics/log_clickthrough.json', params, callback)
43 | }
44 | }
45 |
46 | module.exports = Analytics
47 |
--------------------------------------------------------------------------------
/lib/client.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var request = require('request'),
4 | url = require('url'),
5 | packageJson = require('../package.json')
6 |
7 | var Client = function(config) {
8 | this.config = config
9 | this.clientName = 'elastic-site-search-node'
10 | this.clientVersion = packageJson.version
11 | this.baseUrl = url.format({ protocol: config.protocol, host: config.host, pathname: config.basePath })
12 | }
13 |
14 | Client.prototype = {
15 | get: function(path, params, callback) {
16 | var uri = this._buildUriComponents(path, params)
17 |
18 | request({
19 | method: 'GET',
20 | qs: uri.params,
21 | url: this.baseUrl + uri.path,
22 | auth: {
23 | user: this.config.apiKey
24 | },
25 | headers: {
26 | 'X-Swiftype-Client': this.clientName,
27 | 'X-Swiftype-Client-Version': this.clientVersion
28 | }
29 | }, function(error, response, body) {
30 | if (error)
31 | return callback(error)
32 | else if (!(response.statusCode.toString().match(/2[\d]{2}/)))
33 | return callback(JSON.parse(response.body))
34 | else
35 | return callback(null, JSON.parse(response.body))
36 | })
37 | },
38 |
39 | post: function(path, params, callback) {
40 | var uri = this._buildUriComponents(path, params)
41 |
42 | request({
43 | method: 'POST',
44 | json: uri.params,
45 | url: this.baseUrl + uri.path,
46 | auth: {
47 | user: this.config.apiKey
48 | },
49 | headers: {
50 | 'X-Swiftype-Client': this.clientName,
51 | 'X-Swiftype-Client-Version': this.clientVersion
52 | }
53 | }, function(error, response, body) {
54 | if (error)
55 | return callback(error)
56 | else if (!(response.statusCode.toString().match(/2[\d]{2}/)))
57 | return callback(response.body)
58 | else
59 | return callback(null, response.body)
60 | })
61 | },
62 |
63 | put: function(path, params, callback) {
64 | var uri = this._buildUriComponents(path, params)
65 |
66 | request({
67 | method: 'PUT',
68 | json: uri.params,
69 | url: this.baseUrl + uri.path,
70 | auth: {
71 | user: this.config.apiKey
72 | },
73 | headers: {
74 | 'X-Swiftype-Client': this.clientName,
75 | 'X-Swiftype-Client-Version': this.clientVersion
76 | }
77 | }, function(error, response, body) {
78 | if (error)
79 | return callback(error)
80 | else if (!(response.statusCode.toString().match(/2[\d]{2}/)))
81 | return callback(response.body)
82 | else
83 | return callback(null, response.body)
84 | })
85 | },
86 |
87 | delete: function(path, params, callback) {
88 | var uri = this._buildUriComponents(path, params)
89 |
90 | request({
91 | method: 'DELETE',
92 | url: this.baseUrl + uri.path,
93 | auth: {
94 | user: this.config.apiKey
95 | },
96 | headers: {
97 | 'Accept': '*/*',
98 | 'X-Swiftype-Client': this.clientName,
99 | 'X-Swiftype-Client-Version': this.clientVersion
100 | }
101 | }, function(error, response, body) {
102 | if (error)
103 | return callback(error)
104 | else if (!(response.statusCode.toString().match(/2[\d]{2}/)))
105 | return callback(response)
106 | else
107 | return callback(null, response)
108 | })
109 | },
110 |
111 | _serializeParams: function(obj, prefix) {
112 | var str = [],
113 | isArray = Array.isArray(obj);
114 |
115 | for (var p in obj) {
116 | if (obj.hasOwnProperty(p)) {
117 | var k = "",
118 | v = obj[p];
119 |
120 | if (prefix) {
121 | k += prefix;
122 | k += "[";
123 | if (!isArray) {
124 | k += p;
125 | }
126 | k += "]";
127 | } else {
128 | k = p;
129 | }
130 |
131 | str.push(typeof v == "object" ? this._serializeParams(v, k) : encodeURIComponent(k) + "=" + encodeURIComponent(v));
132 | }
133 | }
134 | return str.join("&");
135 | },
136 |
137 | /*
138 | Parses a path string, replacing '{property}' tags with the
139 | corresponding value from the params object and removes those
140 | properties from the params object.
141 |
142 | > var path = '/engines/{engine}/document_types/{documentType}.json'
143 | > var params = { engine: 'foo', documentType: 'bar', another: 'param' }
144 | > this._buildUri(path, params)
145 | { path: '/engines/foo/document_types/bar.json, params: { another: 'param' } }
146 | */
147 | _buildUriComponents: function(path, params) {
148 | path = path.replace(/{([^{}]*)}/g, function(tag, property) {
149 | var param = params[property]
150 | delete params[property]
151 | return param
152 | })
153 |
154 | return { path: path, params: params }
155 | }
156 |
157 | }
158 |
159 | module.exports = Client
160 |
--------------------------------------------------------------------------------
/lib/documentTypes.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var DocumentTypes = function(client) {
4 | this.client = client
5 | }
6 |
7 | DocumentTypes.prototype = {
8 | list: function(params, callback) {
9 | this.client.get('/engines/{engine}/document_types.json', params, callback)
10 | },
11 |
12 | get: function(params, callback) {
13 | this.client.get('/engines/{engine}/document_types/{documentType}.json', params, callback)
14 | },
15 |
16 | create: function(params, callback) {
17 | this.client.post('/engines/{engine}/document_types.json', params, callback)
18 | },
19 |
20 | search: function(params, callback) {
21 | this.client.get('/engines/{engine}/document_types/{documentType}/search.json', params, callback)
22 | },
23 |
24 | destroy: function(params, callback) {
25 | this.client.delete('/engines/{engine}/document_types/{documentType}', params, callback)
26 | }
27 | }
28 |
29 | module.exports = DocumentTypes
30 |
--------------------------------------------------------------------------------
/lib/documents.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var async = require('async')
4 |
5 | var Documents = function(client) {
6 | this.client = client
7 | }
8 |
9 | Documents.prototype = {
10 |
11 | list: function(params, callback) {
12 | this.client.get('/engines/{engine}/document_types/{documentType}/documents.json', params, callback)
13 | },
14 |
15 | get: function(params, callback) {
16 | this.client.get('/engines/{engine}/document_types/{documentType}/documents/{externalId}.json', params, callback)
17 | },
18 |
19 | create: function(params, callback) {
20 | this.client.post('/engines/{engine}/document_types/{documentType}/documents/create_or_update.json', params, callback)
21 | },
22 |
23 | bulkCreate: function(params, callback) {
24 | this.client.post('/engines/{engine}/document_types/{documentType}/documents/bulk_create_or_update.json', params, callback)
25 | },
26 |
27 | batchCreate: function(params, documents, batchSize, doneCallback){
28 | if (!doneCallback) {
29 | doneCallback = batchSize
30 | batchSize = 10
31 | }
32 |
33 | var batches = []
34 | for (var i=0; i < documents.length; i+=batchSize) {
35 | batches.push(documents.slice(i, i+batchSize));
36 | }
37 |
38 | var _this = this
39 |
40 | var tasks = batches.map(function(batch){
41 | var batchParams = {
42 | engine: params.engine,
43 | documentType: params.documentType,
44 | documents: batch
45 | }
46 | return function(callback){
47 | _this.bulkCreate(batchParams, callback)
48 | }
49 | })
50 |
51 | async.parallel(tasks, doneCallback);
52 | },
53 |
54 |
55 | update: function(params, callback) {
56 | this.client.put('/engines/{engine}/document_types/{documentType}/documents/{externalId}/update_fields.json', params, callback)
57 | },
58 |
59 | destroy: function(params, callback) {
60 | this.client.delete('/engines/{engine}/document_types/{documentType}/documents/{externalId}', params, callback)
61 | },
62 |
63 | bulkDestroy: function(params, callback) {
64 | this.client.post('/engines/{engine}/document_types/{documentType}/documents/bulk_destroy.json', params, callback)
65 | }
66 | }
67 |
68 | module.exports = Documents
69 |
--------------------------------------------------------------------------------
/lib/engines.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Engines = function(client) {
4 | this.client = client
5 | }
6 |
7 | Engines.prototype = {
8 |
9 | list: function(callback) {
10 | this.client.get('/engines.json', {}, callback)
11 | },
12 |
13 | get: function(params, callback) {
14 | this.client.get('/engines/{engine}.json', params, callback)
15 | },
16 |
17 | create: function(params, callback) {
18 | this.client.post('/engines.json', params, callback)
19 | },
20 |
21 | destroy: function(params, callback) {
22 | this.client.delete('/engines/{engine}', params, callback)
23 | }
24 | }
25 |
26 | module.exports = Engines
27 |
--------------------------------------------------------------------------------
/lib/siteSearch.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Client = require('./client'),
4 | Engines = require('./engines'),
5 | DocumentTypes = require('./documentTypes'),
6 | Documents = require('./documents'),
7 | Analytics = require('./analytics')
8 |
9 | var SiteSearchClient = function(config) {
10 | this.config = {
11 | protocol: config.protocol || 'https',
12 | host: config.host || 'api.swiftype.com',
13 | basePath: '/api/v1',
14 | apiKey: config.apiKey,
15 | }
16 |
17 | this.client = new Client(this.config)
18 | this.engines = new Engines(this.client)
19 | this.documentTypes = new DocumentTypes(this.client)
20 | this.documents = new Documents(this.client)
21 | this.analytics = new Analytics(this.client)
22 | }
23 |
24 | SiteSearchClient.prototype = {
25 | search: function(params, callback) {
26 | this.client.post('/engines/{engine}/search.json', params, callback)
27 | },
28 |
29 | suggest: function(params, callback) {
30 | this.client.post('/engines/{engine}/suggest.json', params, callback)
31 | },
32 |
33 | click: function(params, callback) {
34 | this.analytics.logClickthrough(params, callback)
35 | }
36 | }
37 |
38 | module.exports = SiteSearchClient
39 |
--------------------------------------------------------------------------------
/logo-site-search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elastic/site-search-node/0951b448659dc332642497d6854fc4a815ed84f2/logo-site-search.png
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@elastic/site-search-node",
3 | "version": "1.0.1",
4 | "description": "Elastic Site Search API client for Node.js",
5 | "homepage": "https://github.com/elastic/site-search-node",
6 | "main": "lib/siteSearch.js",
7 | "author": "Mike Chlipala",
8 | "license": "Apache-2.0",
9 | "repository": {
10 | "type": "git",
11 | "url": "git@github.com:elastic/site-search-node.git"
12 | },
13 | "engines": {
14 | "node": ">= v4.0"
15 | },
16 | "dependencies": {
17 | "async": "^2.1.4",
18 | "request": "~2.88.0"
19 | },
20 | "devDependencies": {
21 | "mocha": "~5.2.0",
22 | "replay": "~2.1.2"
23 | },
24 | "scripts": {
25 | "test": "mocha"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/test/analyticsTest.js:
--------------------------------------------------------------------------------
1 | var assert = require('assert'),
2 | SiteSearchClient = require('../lib/siteSearch'),
3 | replay = require('replay')
4 |
5 | // Engines and keys fixtures
6 | var myEngine = process.env.SITE_SEARCH_TEST_MY_ENGINE || 'my-engine',
7 | bookstoreEngine = process.env.SITE_SEARCH_TEST_BOOKSTORE_ENGINE || 'bookstore',
8 | temporaryEngine = process.env.SITE_SEARCH_TEST_TEMPORARY_ENGINE || 'temporary',
9 | apiKey = process.env.SITE_SEARCH_TEST_API_KEY || 'a-test-api-key'
10 |
11 | describe('analytics', function() {
12 | var client = new SiteSearchClient({ apiKey: apiKey }),
13 | documentType = 'videos'
14 |
15 | it('gets engine-wide analytics', function(done) {
16 | client.analytics.searches({
17 | engine: bookstoreEngine
18 | }, function(err, res) {
19 | assert(res)
20 | assert.equal(15, res.length)
21 | assert.deepEqual(['2016-11-28', 0], res[0])
22 | done()
23 | })
24 | })
25 |
26 | it('gets engine-wide analytics for a time range', function(done) {
27 | client.analytics.searches({
28 | engine: bookstoreEngine,
29 | start_date: '2014-06-12',
30 | end_date: '2014-06-18'
31 | }, function(err, res) {
32 | assert(res)
33 | assert.deepEqual(['2014-06-18', 0], res[0])
34 | assert.equal(7, res.length)
35 | done()
36 | })
37 | })
38 |
39 | it('gets document-type analytics', function(done) {
40 | client.analytics.searches({
41 | engine: bookstoreEngine,
42 | documentType: documentType
43 | }, function(err, res) {
44 | assert(res)
45 | assert.deepEqual(['2016-11-28', 0], res[0])
46 | assert.equal(15, res.length)
47 | done()
48 | })
49 | })
50 |
51 | it('gets document type analytics for a time range', function(done) {
52 | client.analytics.searches({
53 | engine: bookstoreEngine,
54 | documentType: documentType,
55 | start_date: '2014-06-12',
56 | end_date: '2014-06-18'
57 | }, function(err, res) {
58 | assert(res)
59 | assert.deepEqual(['2014-06-18', 0], res[0])
60 | assert.equal(7, res.length)
61 | done()
62 | })
63 | })
64 |
65 | it('gets engine-wide autoselects for the default time range', function(done) {
66 | client.analytics.autoselects({
67 | engine: bookstoreEngine
68 | }, function(err, res) {
69 | assert(res)
70 | assert.equal(15, res.length)
71 | assert.deepEqual(['2016-11-28', 0], res[0])
72 | done()
73 | })
74 | })
75 |
76 | it('gets engine-wide autoselects for a time range', function(done) {
77 | client.analytics.autoselects({
78 | engine: bookstoreEngine,
79 | start_date: '2014-06-12',
80 | end_date: '2014-06-18'
81 | }, function(err, res) {
82 | assert(res)
83 | assert.equal(7, res.length)
84 | assert.deepEqual(['2014-06-18', 0], res[0])
85 | done()
86 | })
87 | })
88 |
89 | it('gets document type autoselects for the default time range', function(done) {
90 | client.analytics.autoselects({
91 | engine: bookstoreEngine,
92 | documentType: documentType
93 | }, function(err, res) {
94 | assert(res)
95 | assert.equal(15, res.length)
96 | assert.deepEqual(['2016-11-28', 0], res[0])
97 | done()
98 | })
99 | })
100 |
101 | it('gets document type autoselects for a time range', function(done) {
102 | client.analytics.autoselects({
103 | engine: bookstoreEngine,
104 | documentType: documentType,
105 | start_date: '2014-06-12',
106 | end_date: '2014-06-18'
107 | }, function(err, res) {
108 | assert(res)
109 | assert.equal(7, res.length)
110 | assert.deepEqual(['2014-06-18', 0], res[0])
111 | done()
112 | })
113 | })
114 |
115 | it('gets engine-wide clicks for the default time range', function(done) {
116 | client.analytics.clicks({
117 | engine: bookstoreEngine
118 | }, function(err, res) {
119 | assert(res)
120 | assert.equal(15, res.length)
121 | assert.deepEqual(['2016-11-28', 0], res[0])
122 | done()
123 | })
124 | })
125 |
126 | it('gets engine-wide clicks for a time range', function(done) {
127 | client.analytics.clicks({
128 | engine: bookstoreEngine,
129 | start_date: '2014-06-12',
130 | end_date: '2014-06-18'
131 | }, function(err, res) {
132 | assert(res)
133 | assert.equal(7, res.length)
134 | assert.deepEqual(['2014-06-18', 0], res[0])
135 | done()
136 | })
137 | })
138 |
139 | it('gets document type clicks for the default time range', function(done) {
140 | client.analytics.clicks({
141 | engine: bookstoreEngine,
142 | documentType: documentType
143 | }, function(err, res) {
144 | assert(res)
145 | assert.equal(15, res.length)
146 | assert.deepEqual(['2016-11-28', 0], res[0])
147 | done()
148 | })
149 | })
150 |
151 | it('gets document type clicks for a time range', function(done) {
152 | client.analytics.clicks({
153 | engine: bookstoreEngine,
154 | documentType: documentType,
155 | start_date: '2014-06-12',
156 | end_date: '2014-06-18'
157 | }, function(err, res) {
158 | assert(res)
159 | assert.equal(7, res.length)
160 | assert.deepEqual(['2014-06-18', 0], res[0])
161 | done()
162 | })
163 | })
164 |
165 | it('gets top queries', function(done) {
166 | client.analytics.topQueries({
167 | engine: bookstoreEngine
168 | }, function(err, res) {
169 | assert(res)
170 | assert.equal(0, res.length)
171 | done()
172 | })
173 | })
174 |
175 | it('gets top no result queries', function(done) {
176 | client.analytics.topNoResultQueries({
177 | engine: bookstoreEngine
178 | }, function(err, res) {
179 | assert(res)
180 | assert.equal(0, res.length)
181 | done()
182 | })
183 | })
184 |
185 | it('logs the click event', function(done) {
186 | client.click({
187 | engine: myEngine,
188 | q: 'awesome',
189 | id: '5b886b63827a6656794c6eaf',
190 | documentType: 'page'
191 | }, function(err, res) {
192 | assert.equal(null, err)
193 | assert.equal(undefined, res)
194 | done()
195 | })
196 | })
197 | })
198 |
--------------------------------------------------------------------------------
/test/clientTest.js:
--------------------------------------------------------------------------------
1 | var assert = require('assert'),
2 | SiteSearchClient = require('../lib/siteSearch'),
3 | replay = require('replay')
4 |
5 | // Engines and keys fixtures
6 | var myEngine = process.env.SITE_SEARCH_TEST_MY_ENGINE || 'my-engine',
7 | bookstoreEngine = process.env.SITE_SEARCH_TEST_BOOKSTORE_ENGINE || 'bookstore',
8 | temporaryEngine = process.env.SITE_SEARCH_TEST_TEMPORARY_ENGINE || 'temporary',
9 | apiKey = process.env.SITE_SEARCH_TEST_API_KEY || 'a-test-api-key'
10 |
11 | describe('client', function() {
12 | it('encodes parameters', function() {
13 | var siteSearchClient = new SiteSearchClient({ apiKey: apiKey })
14 |
15 | assert.equal('foo%5B%5D=1&foo%5B%5D=2&bar%5Bbaz%5D%5B%5D=a&bar%5Bbaz%5D%5B%5D=b', siteSearchClient.client._serializeParams({foo: [1, 2], bar: {baz: ['a', 'b']}}))
16 | })
17 | })
18 |
--------------------------------------------------------------------------------
/test/documentTypesTest.js:
--------------------------------------------------------------------------------
1 | var assert = require('assert'),
2 | SiteSearchClient = require('../lib/siteSearch'),
3 | replay = require('replay')
4 |
5 | // Engines and keys fixtures
6 | var myEngine = process.env.SITE_SEARCH_TEST_MY_ENGINE || 'my-engine',
7 | bookstoreEngine = process.env.SITE_SEARCH_TEST_BOOKSTORE_ENGINE || 'bookstore',
8 | temporaryEngine = process.env.SITE_SEARCH_TEST_TEMPORARY_ENGINE || 'temporary',
9 | apiKey = process.env.SITE_SEARCH_TEST_API_KEY || 'a-test-api-key'
10 |
11 | describe('documentTypes', function() {
12 | var client = new SiteSearchClient({ apiKey: apiKey })
13 |
14 | it('gets the document types for an engine', function(done) {
15 | client.documentTypes.list({engine: bookstoreEngine}, function(err, res) {
16 | assert(res)
17 | assert.equal(2, res.length)
18 | done()
19 | })
20 | })
21 |
22 | it('gets the document type', function(done) {
23 | var documentType = 'books'
24 | client.documentTypes.get({engine: bookstoreEngine, documentType: documentType}, function(err, res) {
25 | assert(res)
26 | assert.equal(documentType, res.slug)
27 | done()
28 | })
29 | })
30 |
31 | it('creates a document type', function(done) {
32 | var documentType = { name: 'magazines' }
33 | client.documentTypes.create({engine: bookstoreEngine, document_type: documentType}, function(err, res) {
34 | assert(res)
35 | assert.equal(documentType.name, res.name)
36 | done()
37 | })
38 | })
39 |
40 | it('searches document types', function(done) {
41 | var documentType = 'books'
42 | client.documentTypes.search({
43 | engine: bookstoreEngine,
44 | documentType: documentType,
45 | q: 'Gatsby'
46 | }, function(err, res) {
47 | assert(res)
48 | assert.equal(res.record_count, 0);
49 | done()
50 | })
51 | })
52 |
53 | it('destroys a document type', function(done) {
54 | var documentType = 'magazines'
55 | client.documentTypes.destroy({
56 | engine: bookstoreEngine,
57 | documentType: documentType
58 | }, function(err, res) {
59 | assert(res)
60 | assert.equal(204, res.statusCode)
61 | done()
62 | })
63 | })
64 | })
65 |
--------------------------------------------------------------------------------
/test/documentsTest.js:
--------------------------------------------------------------------------------
1 | var assert = require('assert'),
2 | SiteSearchClient = require('../lib/siteSearch'),
3 | replay = require('replay')
4 |
5 | // Engines and keys fixtures
6 | var myEngine = process.env.SITE_SEARCH_TEST_MY_ENGINE || 'my-engine',
7 | bookstoreEngine = process.env.SITE_SEARCH_TEST_BOOKSTORE_ENGINE || 'bookstore',
8 | temporaryEngine = process.env.SITE_SEARCH_TEST_TEMPORARY_ENGINE || 'temporary',
9 | apiKey = process.env.SITE_SEARCH_TEST_API_KEY || 'a-test-api-key'
10 |
11 | describe('documents', function() {
12 | var client = new SiteSearchClient({ apiKey: apiKey }),
13 | documentType = 'books'
14 |
15 | it('creates a document', function(done) {
16 | var document = {
17 | external_id: '1',
18 | fields: [
19 | { name: 'title', value: 'The Great Gatsby', type: 'string' },
20 | { name: 'author', value: 'F. Scott Fitzgerald', type: 'string' },
21 | { name: 'genre', value: 'fiction', type: 'enum' }
22 | ]
23 | }
24 |
25 | client.documents.create({
26 | engine: bookstoreEngine,
27 | documentType: documentType,
28 | document: document
29 | }, function(err, res) {
30 | assert(res)
31 | assert.equal(document.external_id, res.external_id)
32 | done()
33 | })
34 | })
35 |
36 | it('creates multiple documents', function(done) {
37 | var documents = [
38 | {external_id: '3', fields: [ { name: 'title', value: 'A Great Book', type: 'string' } ]},
39 | {external_id: '4', fields: [ { name: 'title', value: 'Another Great Book', type: 'string' } ]},
40 | ]
41 |
42 | client.documents.bulkCreate({
43 | engine: bookstoreEngine,
44 | documentType: documentType,
45 | documents: documents
46 | }, function(err, res) {
47 | assert(res)
48 | assert.equal(2, res.length)
49 | done()
50 | })
51 | })
52 |
53 | it('creates multiple documents in batches', function(done) {
54 | // node-replay doesn't nicely support mulitple requests to the same url
55 | // because it exports a singleton, so mutations in one test might affect other tests, so
56 | // this test just checks that you've correctly delegated to the documents.bulkCreate
57 | // https://github.com/assaf/node-replay/issues/52
58 | var documents = [
59 | {external_id: '3', fields: [ { name: 'title', value: 'A Great Book', type: 'string' } ]},
60 | {external_id: '4', fields: [ { name: 'title', value: 'Another Great Book', type: 'string' } ]},
61 | ]
62 |
63 | var batchSize = 1
64 |
65 | var passedOptions = []
66 |
67 | var _bulkCreate = client.documents.bulkCreate
68 | client.documents.bulkCreate = function(options, callback){
69 | assert.equal(batchSize, options.documents.length)
70 | passedOptions.push(options)
71 | callback(null, {})
72 | }
73 |
74 | var options = {
75 | engine: bookstoreEngine,
76 | documentType: documentType,
77 | }
78 |
79 | var batchSize = 1
80 |
81 | client.documents.batchCreate(options, documents, batchSize, function(err, res) {
82 | assert.equal(2, passedOptions.length)
83 | client.documents.bulkCreate = _bulkCreate
84 | done()
85 | })
86 | })
87 |
88 | it('gets a document', function(done) {
89 | client.documents.get({
90 | engine: bookstoreEngine,
91 | documentType: documentType,
92 | externalId: '1'
93 | }, function(err, res) {
94 | assert(res)
95 | assert.equal('The Great Gatsby', res.title)
96 | done()
97 | })
98 | })
99 |
100 | it('gets all the documents', function(done) {
101 | client.documents.list({
102 | engine: bookstoreEngine,
103 | documentType: documentType
104 | }, function(err, res) {
105 | assert(res)
106 | assert.equal(3, res.length)
107 | done()
108 | })
109 | })
110 |
111 | it('updates a document', function(done) {
112 | var field = { title: 'This Side of Paradise' }
113 |
114 | client.documents.update({
115 | engine: bookstoreEngine,
116 | documentType: documentType,
117 | externalId: '1',
118 | fields: field
119 | }, function(err, res) {
120 | assert(res)
121 | assert.equal(field.title, res.title)
122 | done()
123 | })
124 | })
125 |
126 | it('destroys a document', function(done) {
127 | client.documents.destroy({
128 | engine: bookstoreEngine,
129 | documentType: documentType,
130 | externalId: '1'
131 | }, function(err, res) {
132 | assert.equal(res.statusCode, 204)
133 | done()
134 | })
135 | })
136 |
137 | it('destroys multiple documents', function(done) {
138 | client.documents.bulkDestroy({
139 | engine: bookstoreEngine,
140 | documentType: documentType,
141 | documents: [ '3', '4' ]
142 | }, function(err, res) {
143 | assert(res)
144 | assert.equal(2, res.length)
145 | done()
146 | })
147 | })
148 | })
149 |
--------------------------------------------------------------------------------
/test/enginesTest.js:
--------------------------------------------------------------------------------
1 | var assert = require('assert'),
2 | SiteSearchClient = require('../lib/siteSearch'),
3 | replay = require('replay')
4 |
5 | // Engines and keys fixtures
6 | var myEngine = process.env.SITE_SEARCH_TEST_MY_ENGINE || 'my-engine',
7 | bookstoreEngine = process.env.SITE_SEARCH_TEST_BOOKSTORE_ENGINE || 'bookstore',
8 | temporaryEngine = process.env.SITE_SEARCH_TEST_TEMPORARY_ENGINE || 'temporary',
9 | apiKey = process.env.SITE_SEARCH_TEST_API_KEY || 'a-test-api-key'
10 |
11 | describe('engines', function() {
12 | var client = new SiteSearchClient({ apiKey: apiKey })
13 |
14 | it('gets the engines', function(done) {
15 | client.engines.list(function(err, res) {
16 | assert(res)
17 | assert.equal(2, res.length)
18 | done()
19 | })
20 | })
21 |
22 | it('gets an engine', function(done) {
23 | client.engines.get({engine: myEngine}, function(err, res) {
24 | assert(res)
25 | assert.equal(myEngine, res.slug)
26 | done()
27 | })
28 | })
29 |
30 | it('creates an engine', function(done) {
31 | var engine = { name: temporaryEngine }
32 | client.engines.create({engine: engine}, function(err, res) {
33 | assert(res)
34 | assert.equal(engine.name, res.name)
35 | done()
36 | })
37 | })
38 |
39 | it('destroys an engine', function(done) {
40 | client.engines.destroy({
41 | engine: temporaryEngine
42 | }, function(err, res) {
43 | assert(res)
44 | assert.equal(204, res.statusCode)
45 | done()
46 | })
47 | })
48 | })
49 |
--------------------------------------------------------------------------------
/test/siteSearchTest.js:
--------------------------------------------------------------------------------
1 | var assert = require('assert'),
2 | SiteSearchClient = require('../lib/siteSearch'),
3 | replay = require('replay')
4 |
5 | // Engines and keys fixtures
6 | var myEngine = process.env.SITE_SEARCH_TEST_MY_ENGINE || 'my-engine',
7 | bookstoreEngine = process.env.SITE_SEARCH_TEST_BOOKSTORE_ENGINE || 'bookstore',
8 | temporaryEngine = process.env.SITE_SEARCH_TEST_TEMPORARY_ENGINE || 'temporary',
9 | apiKey = process.env.SITE_SEARCH_TEST_API_KEY || 'a-test-api-key'
10 |
11 | describe('siteSearch', function() {
12 | describe('config', function() {
13 | it('sets the API key', function() {
14 | var client = new SiteSearchClient({ apiKey: apiKey })
15 |
16 | assert.equal(apiKey, client.config.apiKey)
17 | })
18 | })
19 |
20 | describe('search', function() {
21 | var client = new SiteSearchClient({ apiKey: apiKey })
22 |
23 | it('searches an engine', function(done) {
24 | client.search({engine: myEngine, q: 'awesome'}, function(err, res) {
25 | assert(res)
26 | assert.equal('Asana Case Study | Swiftype', res.records.page[0].title)
27 | done()
28 | })
29 | })
30 | })
31 |
32 | describe('suggest', function() {
33 | var client = new SiteSearchClient({ apiKey: apiKey })
34 |
35 | it('autocompletes on an engine', function(done) {
36 | client.suggest({engine: myEngine, q: 'awe'}, function(err, res) {
37 | assert(res)
38 | assert.equal('Asana Case Study | Swiftype', res.records.page[0].title)
39 | done()
40 | })
41 | })
42 | })
43 |
44 | describe('click', function() {
45 | var client = new SiteSearchClient({ apiKey: apiKey })
46 |
47 | it('logs the click event', function(done) {
48 | client.click({
49 | engine: myEngine,
50 | q: 'awesome',
51 | id: '5b886b63827a6656794c6eaf',
52 | documentType: 'page'
53 | }, function(err, res) {
54 | assert.equal(null, err)
55 | assert.equal(undefined, res)
56 | done()
57 | })
58 | })
59 | })
60 | })
61 |
--------------------------------------------------------------------------------