This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pywikibot | |
from pywikibot import pagegenerators | |
from elasticsearch import Elasticsearch | |
import json | |
es = Elasticsearch() | |
data = {} | |
site = pywikibot.Site() | |
cat = pywikibot.Category(site,'Category:Living people') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PUT wikipeople | |
{ | |
"mappings": { | |
"wiki_page": { | |
"properties": { | |
"text": { | |
"type": "text", | |
"fields": { | |
"english": { | |
"type": "text", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET wikipeople/_search | |
{ | |
"_source": { | |
"excludes": [ "text" ] | |
}, | |
"query": { | |
"bool": { | |
"should": [ | |
{ "match": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST wikipeople/_search?pretty | |
{ | |
"_source": { | |
"excludes": [ "text" ] | |
}, | |
"suggest": { | |
"people-suggest" : { | |
"prefix" : "ada", | |
"completion" : { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PUT user_purchases | |
{ | |
"mappings": { | |
"user_history": { | |
"properties": { | |
"user_id":{ | |
"type": "text", | |
"fields": { | |
"raw": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST user_purchases/_search? | |
{ | |
"size": 0, | |
"query": { | |
"bool": { | |
"filter": [ | |
{ "term": { "product_id.raw": "polaroid x1566" }} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Analyzer for SKUs | |
The analyzer below will strip out any of the items defined in the regex. In this case i am removing -#_ and any whitespace. | |
You can adapt the regex as appropriate. In this case the search WILL be case sensitive. | |
As a keyword tokenizer is used, then the text will not be split into "words" . | |
``` | |
PUT my-index-000001 | |
{ |