1
- <p align =" center " ><img src =" https://github.com/swiftype/swiftype-py /blob/master/logo-site-search.png?raw=true " alt =" Elastic Site Search Logo " ></p >
1
+ <p align =" center " ><img src =" https://github.com/elastic/site-search-python /blob/master/logo-site-search.png?raw=true " alt =" Elastic Site Search Logo " ></p >
2
2
3
- <p align =" center " ><a href =" https://travis-ci.org/swiftype/swiftype-py " ><img src =" https://travis-ci.org/swiftype/swiftype-py .png?branch=master " alt =" Travis build " ></a >
4
- <a href =" https://github.com/swiftype/swiftype-py /releases " ><img src =" https://img.shields.io/github/release/swiftype/swiftype-py /all.svg?style=flat-square " alt =" GitHub release " /></a ></p >
3
+ <p align =" center " ><a href =" https://travis-ci.org/elastic/site-search-python " ><img src =" https://travis-ci.org/elastic/site-search-python .png?branch=master " alt =" Travis build " ></a >
4
+ <a href =" https://github.com/elastic/site-search-python /releases " ><img src =" https://img.shields.io/github/release/elastic/site-search-python /all.svg?style=flat-square " alt =" GitHub release " /></a ></p >
5
5
6
6
> A first-party Python client for the [ Elastic Site Search API] ( https://swiftype.com/documentation/site-search/overview ) .
7
7
18
18
19
19
## Getting started 🐣
20
20
21
- You can install the latest version of the Swiftype client using ` pip ` :
21
+ You can install the latest version of the Elastic Site Search client using ` pip ` :
22
22
23
23
``` bash
24
24
pip install elastic-site-search
@@ -34,7 +34,7 @@ To install locally, clone this repository, `cd` into the directory and run:
34
34
35
35
## Usage
36
36
37
- 1 . Create an account at [ Swiftype ] ( https://swiftype.com/ ) and get your API key from your [ Account Settings] ( https://app.swiftype.com/settings/account ) .
37
+ 1 . Create [ Elastic Site Search account ] ( https://swiftype.com/ ) and get your API key from your [ Account Settings] ( https://app.swiftype.com/settings/account ) .
38
38
39
39
2 . Configure your client:
40
40
@@ -66,8 +66,8 @@ Add a `Document` to the `videos` `DocumentType`:
66
66
client.create_document(' youtube' , ' videos' , {
67
67
' external_id' : ' external_id1' ,
68
68
' fields' : [
69
- {' name' : ' title' , ' value' : ' Swiftype Demo' , ' type' : ' string' },
70
- {' name' : ' tags' , ' value' : [' Swiftype ' , ' Search' , ' Full text search' ], ' type' : ' string' },
69
+ {' name' : ' title' , ' value' : ' Site Search Demo' , ' type' : ' string' },
70
+ {' name' : ' tags' , ' value' : [' Site Search ' , ' Search' , ' Full text search' ], ' type' : ' string' },
71
71
{' name' : ' url' , ' value' : ' http://www.youtube.com/watch?v=pITuOcGgpBs' , ' type' : ' enum' },
72
72
{' name' : ' category' , ' value' : [' Tutorial' , ' Product' ], ' type' : ' enum' },
73
73
{' name' : ' publication_date' , ' value' : ' 2012-05-08T12:07Z' , ' type' : ' date' },
@@ -83,8 +83,8 @@ Add a `Document` to the `channels` `DocumentType`:
83
83
client.create_document(' youtube' , ' channels' , {
84
84
' external_id' : ' external_id1' ,
85
85
' fields' : [
86
- {' name' : ' title' , ' value' : ' Swiftype ' , ' type' : ' string' },
87
- {' name' : ' url' , ' value' : ' http://www.youtube.com/user/swiftype ' , ' type' : ' enum' },
86
+ {' name' : ' title' , ' value' : ' Elastic ' , ' type' : ' string' },
87
+ {' name' : ' url' , ' value' : ' http://www.youtube.com/user/elasticsearch ' , ' type' : ' enum' },
88
88
{' name' : ' video_views' , ' value' : 15678 , ' type' : ' integer' },
89
89
{' name' : ' video_counts' , ' value' : 6 , ' type' : ' integer' }
90
90
]
@@ -96,28 +96,28 @@ Add a `Document` to the `channels` `DocumentType`:
96
96
Now your ` Engine ` is ready to receive queries. By default, search queries will match any fields that are of type ` string ` or ` text ` . You can search each ` DocumentType ` individually:
97
97
98
98
``` python
99
- video_results = client.search_document_type(' youtube' , ' videos' , ' swiftype ' )
100
- channel_results = client.search_document_type(' youtube' , ' channels' , ' swiftype ' )
99
+ video_results = client.search_document_type(' youtube' , ' videos' , ' site search ' )
100
+ channel_results = client.search_document_type(' youtube' , ' channels' , ' site search ' )
101
101
```
102
102
103
103
or search all ` DocumentType ` s on your ` Engine ` at once:
104
104
105
105
``` python
106
- results = client.search(' youtube' , ' swiftype ' )
106
+ results = client.search(' youtube' , ' site search ' )
107
107
```
108
108
109
109
### Autocomplete
110
110
111
111
Finally, as with full-text searches, you may perform autocomplete-style (prefix match) searches as well:
112
112
113
113
``` python
114
- results = client.suggest(' youtube' , ' swi ' )
114
+ results = client.suggest(' youtube' , ' sit ' )
115
115
```
116
116
117
117
or
118
118
119
119
``` python
120
- results = client.suggest_document_type(' youtube' , ' videos' , ' swi ' )
120
+ results = client.suggest_document_type(' youtube' , ' videos' , ' sit ' )
121
121
```
122
122
123
123
## API Documentation
@@ -135,42 +135,42 @@ You can find your API key in your [Account Settings](https://swiftype.com/user/e
135
135
136
136
### Search
137
137
138
- If you want to search for e.g. ` swiftype ` on your ` Engine ` , you can use:
138
+ If you want to search for e.g. ` site search ` on your ` Engine ` , you can use:
139
139
140
140
``` python
141
- results = client.search(' youtube' , ' swiftype ' )
141
+ results = client.search(' youtube' , ' site search ' )
142
142
```
143
143
144
144
To limit the search to only the ` videos ` DocumentType:
145
145
146
146
``` python
147
- results = client.search_document_type(' youtube' , ' videos' , ' swiftype ' )
147
+ results = client.search_document_type(' youtube' , ' videos' , ' site search ' )
148
148
```
149
149
150
150
Both search methods allow you to specify options as an extra parameter to e.g. filter or sort on fields. For more details on these options please have a look at the [ Search Options] ( https://swiftype.com/documentation/searching ) . Here is an example for showing only ` videos ` that are in the ` category ` ` Tutorial ` :
151
151
152
152
``` python
153
- results = client.search_document_type(' youtube' , ' videos' , ' swiftype ' , {' filters' : {' videos' : {' category' : ' Tutorial' }}})
153
+ results = client.search_document_type(' youtube' , ' videos' , ' site search ' , {' filters' : {' videos' : {' category' : ' Tutorial' }}})
154
154
```
155
155
156
156
### Autocomplete
157
157
158
158
Autocompletes have the same functionality as searches. You can autocomplete using all documents:
159
159
160
160
``` python
161
- results = client.suggest(' youtube' , ' swi ' )
161
+ results = client.suggest(' youtube' , ' sit ' )
162
162
```
163
163
164
164
or just for one DocumentType:
165
165
166
166
``` python
167
- results = client.suggest_document_type(' youtube' , ' videos' , ' swi ' )
167
+ results = client.suggest_document_type(' youtube' , ' videos' , ' sit ' )
168
168
```
169
169
170
170
or add options to have more control over the results:
171
171
172
172
``` python
173
- results = client.suggest(' youtube' , ' swi ' , {' sort_field' : {' videos' : ' likes' }})
173
+ results = client.suggest(' youtube' , ' sit ' , {' sort_field' : {' videos' : ' likes' }})
174
174
```
175
175
176
176
### Engines
@@ -251,8 +251,8 @@ Create a new `Document` with mandatory `external_id` and user-defined fields:
251
251
document = client.create_document(' youtube' , ' videos' , {
252
252
' external_id' : ' external_id1' ,
253
253
' fields' : [
254
- {' name' : ' title' , ' value' : ' Swiftype Demo' , ' type' : ' string' },
255
- {' name' : ' tags' , ' value' : [' Swiftype ' , ' Search' , ' Full text search' ], ' type' : ' string' },
254
+ {' name' : ' title' , ' value' : ' Site Search Demo' , ' type' : ' string' },
255
+ {' name' : ' tags' , ' value' : [' Site Search ' , ' Search' , ' Full text search' ], ' type' : ' string' },
256
256
{' name' : ' url' , ' value' : ' http://www.youtube.com/watch?v=pITuOcGgpBs' , ' type' : ' enum' },
257
257
{' name' : ' category' , ' value' : [' Tutorial' , ' Product' ], ' type' : ' enum' },
258
258
{' name' : ' publication_date' , ' value' : ' 2012-05-08T12:07Z' , ' type' : ' date' },
@@ -269,8 +269,8 @@ Create multiple `Document`s at once and return status for each `Document` creati
269
269
{
270
270
' external_id' : ' external_id1' ,
271
271
' fields' : [
272
- {' name' : ' title' , ' value' : ' Swiftype Demo' , ' type' : ' string' },
273
- {' name' : ' tags' , ' value' : [' Swiftype ' , ' Search' , ' Full text search' ], ' type' : ' string' },
272
+ {' name' : ' title' , ' value' : ' Site Search Demo' , ' type' : ' string' },
273
+ {' name' : ' tags' , ' value' : [' Site Search ' , ' Search' , ' Full text search' ], ' type' : ' string' },
274
274
{' name' : ' url' , ' value' : ' http://www.youtube.com/watch?v=pITuOcGgpBs' , ' type' : ' enum' },
275
275
{' name' : ' category' , ' value' : [' Tutorial' , ' Product' ], ' type' : ' enum' },
276
276
{' name' : ' publication_date' , ' value' : ' 2012-05-08T12:07Z' , ' type' : ' date' },
@@ -281,8 +281,8 @@ Create multiple `Document`s at once and return status for each `Document` creati
281
281
{
282
282
' external_id' : ' external_id2' ,
283
283
' fields' : [
284
- {' name' : ' title' , ' value' : ' Swiftype Search Wordpress Plugin Demo' , ' type' : ' string' },
285
- {' name' : ' tags' , ' value' : [' Swiftype ' , ' Search' , ' Full text search' , ' WordPress' ], ' type' : ' string' },
284
+ {' name' : ' title' , ' value' : ' Site Search Search Wordpress Plugin Demo' , ' type' : ' string' },
285
+ {' name' : ' tags' , ' value' : [' Site Search ' , ' Search' , ' Full text search' , ' WordPress' ], ' type' : ' string' },
286
286
{' name' : ' url' , ' value' : ' http://www.youtube.com/watch?v=rukXYKEpvS4' , ' type' : ' enum' },
287
287
{' name' : ' category' , ' value' : [' Tutorial' , ' Wordpress' ], ' type' : ' enum' },
288
288
{' name' : ' publication_date' , ' value' : ' 2012-08-15T09:07Z' , ' type' : ' date' },
@@ -314,8 +314,8 @@ Create or update a `Document`:
314
314
document = client.create_or_update_document(' youtube' , ' videos' , {
315
315
' external_id' : ' external_id3' ,
316
316
' fields' : [
317
- {' name' : ' title' , ' value' : ' Swiftype Install Type 1: Show results in an overlay' , ' type' : ' string' },
318
- {' name' : ' tags' , ' value' : [' Swiftype ' , ' Search' , ' Full text search' , ' Web' ], ' type' : ' string' },
317
+ {' name' : ' title' , ' value' : ' Site Search Install Type 1: Show results in an overlay' , ' type' : ' string' },
318
+ {' name' : ' tags' , ' value' : [' Site Search ' , ' Search' , ' Full text search' , ' Web' ], ' type' : ' string' },
319
319
{' name' : ' url' , ' value' : ' http://www.youtube.com/watch?v=mj2ApIx3frs' , ' type' : ' enum' }
320
320
]
321
321
})
@@ -328,16 +328,16 @@ Create or update multiple `Documents` at once:
328
328
{
329
329
' external_id' : ' external_id4' ,
330
330
' fields' : [
331
- {' name' : ' title' , ' value' : ' Swiftype Install Type 2: Show results on the current page' , ' type' : ' string' },
332
- {' name' : ' tags' , ' value' : [' Swiftype ' , ' Search' , ' Full text search' , ' Web' ], ' type' : ' string' },
331
+ {' name' : ' title' , ' value' : ' Site Search Install Type 2: Show results on the current page' , ' type' : ' string' },
332
+ {' name' : ' tags' , ' value' : [' Site Search ' , ' Search' , ' Full text search' , ' Web' ], ' type' : ' string' },
333
333
{' name' : ' url' , ' value' : ' http://www.youtube.com/watch?v=6uaZXYK2WOE' , ' type' : ' enum' }
334
334
]
335
335
},
336
336
{
337
337
' external_id' : ' external_id5' ,
338
338
' fields' : [
339
- {' name' : ' title' , ' value' : ' Swiftype Install Type 3: Show results on a new page' , ' type' : ' string' },
340
- {' name' : ' tags' , ' value' : [' Swiftype ' , ' Search' , ' Full text search' , ' Web' ], ' type' : ' string' },
339
+ {' name' : ' title' , ' value' : ' Site Search Install Type 3: Show results on a new page' , ' type' : ' string' },
340
+ {' name' : ' tags' , ' value' : [' Site Search ' , ' Search' , ' Full text search' , ' Web' ], ' type' : ' string' },
341
341
{' name' : ' url' , ' value' : ' http://www.youtube.com/watch?v=ebSWAscBPtc' , ' type' : ' enum' }
342
342
]
343
343
}
@@ -369,10 +369,10 @@ Retrieve a specific `Domain` by `id`:
369
369
domain = client.domain(' websites' , ' generated_id' )
370
370
```
371
371
372
- Create a new ` Domain ` with the URL ` https://swiftype.com ` and start crawling:
372
+ Create a new ` Domain ` with the URL ` https://elastic.co ` and start crawling:
373
373
374
374
``` python
375
- domain = client.create_domain(' websites' , ' https://swiftype.com ' )
375
+ domain = client.create_domain(' websites' , ' https://elastic.co ' )
376
376
```
377
377
378
378
Delete a ` Domain ` using its ` id ` :
@@ -390,7 +390,7 @@ Initiate a recrawl of a specific `Domain` using its `id`:
390
390
Add or update a URL for a ` Domain ` :
391
391
392
392
``` python
393
- client.crawl_url(' websites' , ' generated_id' , ' https://swiftype.com /new/path/about.html' )
393
+ client.crawl_url(' websites' , ' generated_id' , ' https://elastic.co /new/path/about.html' )
394
394
```
395
395
396
396
### Analytics
@@ -451,14 +451,14 @@ You can also specify a date range for no result queries:
451
451
452
452
``` bash
453
453
pip install -r test_requirements.txt
454
- python tests/test_swiftype .py
454
+ python tests/test_client .py
455
455
```
456
456
457
457
## FAQ 🔮
458
458
459
459
### Where do I report issues with the client?
460
460
461
- If something is not working as expected, please open an [ issue] ( https://github.com/swiftype/swiftype-py /issues/new ) .
461
+ If something is not working as expected, please open an [ issue] ( https://github.com/elastic/site-search-python /issues/new ) .
462
462
463
463
### Where can I learn more about Site Search?
464
464
@@ -472,7 +472,7 @@ You can checkout the [Elastic Site Search community discuss forums](https://disc
472
472
473
473
We welcome contributors to the project. Before you begin, a couple notes...
474
474
475
- + Before opening a pull request, please create an issue to [ discuss the scope of your proposal] ( https://github.com/swiftype/swiftype-py /issues ) .
475
+ + Before opening a pull request, please create an issue to [ discuss the scope of your proposal] ( https://github.com/elastic/site-search-python /issues ) .
476
476
+ Please write simple code and concise documentation, when appropriate.
477
477
478
478
## License 📗
0 commit comments