33
loading...
This website collects cookies to deliver better user experience
mkdir -p ES_DATA && docker run -v $(pwd)/ES_DATA:/usr/share/elasticsearch/data -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms750m -Xmx750m" -p 9200:9200 elasticsearch:7.12.0
dineshsonachalam@macbook ~ % curl --location --request GET 'http://elasticsearch:9200/_cat/health'
1629473241 15:27:21 docker-cluster green 1 1 0 0 0 0 0 0 - 100.0%
curl -X PUT "elasticsearch:9200/_index_template/template_1?pretty" -H 'Content-Type: application/json' \
-d'{
"index_patterns": "cs.stanford",
"template": {
"settings": {
"number_of_shards": 1
},
"mappings": {
"_source": {
"enabled": true
},
"properties": {
"topic": {
"type": "text"
},
"title": {
"type": "completion"
},
"url": {
"type": "text"
},
"labels": {
"type": "text"
},
"upvotes": {
"type": "integer"
}
}
}
}
}'
dineshsonachalam@macbook ~ % curl --location --request GET 'http://elasticsearch:9200/_index_template/template_1'
{
"index_templates": [
{
"name": "template_1",
"index_template": {
"index_patterns": [
"cs.stanford"
],
"template": {
"settings": {
"index": {
"number_of_shards": "1"
}
},
"mappings": {
"_source": {
"enabled": true
},
"properties": {
"upvotes": {
"type": "integer"
},
"topic": {
"type": "text"
},
"title": {
"type": "completion"
},
"url": {
"type": "text"
},
"labels": {
"type": "text"
}
}
}
},
"composed_of": []
}
}
]
}
dineshsonachalam@macbook ~ % curl --location --request PUT 'http://elasticsearch:9200/cs.stanford/'
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "cs.stanford"
}
dineshsonachalam@macbook ~ % curl --location --request GET 'http://elasticsearch:9200/cs.stanford/'
{
"cs.stanford": {
"aliases": {},
"mappings": {
"properties": {
"labels": {
"type": "text"
},
"title": {
"type": "completion",
"analyzer": "simple",
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50
},
"topic": {
"type": "text"
},
"upvotes": {
"type": "integer"
},
"url": {
"type": "text"
}
}
},
"settings": {
"index": {
"routing": {
"allocation": {
"include": {
"_tier_preference": "data_content"
}
}
},
"number_of_shards": "1",
"provided_name": "cs.stanford",
"creation_date": "1629526849180",
"number_of_replicas": "1",
"uuid": "NrvQ6juOSNmf0GOPO2QADA",
"version": {
"created": "7120099"
}
}
}
}
}
cd backend && python -c 'from utils.elasticsearch import Elasticsearch; es = Elasticsearch("cs.stanford"); es.add_documents()' && cd ..
dineshsonachalam@macbook tech-courses-search-engine % curl --location --request GET 'http://elasticsearch:9200/cs.stanford/_count'
{
"count": 1350,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
}
}
dineshsonachalam@macbook tech-courses-search-engine % cd backend && python -c 'from utils.filters import SearchFilters; search = SearchFilters("cs.stanford"); print(search.autocomplete(query="python"))' && cd ..
[
{
"id": 1,
"value": "Python Data Science Handbook"
},
{
"id": 2,
"value": "Python Game Programming Tutorial: SpaceWar"
},
{
"id": 3,
"value": "Python for Beginners - Learn Python Programming La"
},
{
"id": 4,
"value": "Python for Data Science and Machine Learning Bootc"
},
{
"id": 5,
"value": "Python for Security Professionals"
}
]
sh dev-startup.sh
GET /autocomplete
Parameter | Type | Description |
---|---|---|
query |
string |
Required. Query string |
dineshsonachalam@macbook ~ % curl --location --request GET 'elasticsearch:8000/autocomplete?query=python'
[
{
"id": 1,
"value": "Python Data Science Handbook"
},
{
"id": 2,
"value": "Python GUI with Tkinter Playlist"
},
{
"id": 3,
"value": "Python Game Programming Tutorial: SpaceWar"
},
{
"id": 4,
"value": "Python PostgreSQL Tutorial Using Psycopg2"
},
{
"id": 5,
"value": "Python Programming for the Raspberry Pi"
}
]
POST /string-query-search
Parameter | Type | Description |
---|---|---|
query |
string |
Required. Query string |
dineshsonachalam@macbook ~ % curl --location --request POST 'elasticsearch:8000/string-query-search?query=python'
[
{
"id": 1,
"title": "Google's Python Class",
"topic": "Python",
"url": "https://developers.google.com/edu/python/",
"labels": [
"Free",
"Python 2"
],
"upvotes": 213
},
{
"id": 2,
"title": "Complete Python Bootcamp",
"topic": "Python",
"url": "https://click.linksynergy.com/deeplink?id=jU79Zysihs4&mid=39197&murl=https://www.udemy.com/complete-python-bootcamp",
"labels": [
"Paid",
"Video",
"Beginner",
"Python 3"
],
"upvotes": 196
},
{
"id": 3,
"title": "Automate the Boring Stuff with Python",
"topic": "Python",
"url": "http://automatetheboringstuff.com/",
"labels": [
"Free",
"Book"
],
"upvotes": 93
},
{
"id": 4,
"title": "Official Python Tutorial",
"topic": "Python",
"url": "https://docs.python.org/3/tutorial/index.html",
"labels": [
"Free"
],
"upvotes": 74
},
{
"id": 5,
"title": "Working with Strings in Python",
"topic": "Python",
"url": "https://academy.vertabelo.com/course/python-strings",
"labels": [
"Free",
"Beginner",
"Python 3"
],
"upvotes": 4
},
{
"id": 6,
"title": "Learn Python the Hard Way",
"topic": "Python",
"url": "https://learnpythonthehardway.org/book/",
"labels": [
"Paid",
"Book",
"Python 3"
],
"upvotes": 293
},
{
"id": 7,
"title": "Python for Beginners - Learn Python Programming Language in 2 Hours",
"topic": "Python",
"url": "https://www.youtube.com/watch?v=yE9v9rt6ziw",
"labels": [
"Free",
"Video",
"Beginner",
"Python 3"
],
"upvotes": 62
},
{
"id": 8,
"title": "Automate the Boring Stuff with Python",
"topic": "Python",
"url": "https://click.linksynergy.com/deeplink?id=jU79Zysihs4&mid=39197&murl=https://www.udemy.com/automate/",
"labels": [
"Paid",
"Video",
"Beginner"
],
"upvotes": 45
},
{
"id": 9,
"title": "Introduction to Programming with Python",
"topic": "Python",
"url": "https://mva.microsoft.com/en-US/training-courses/introduction-to-programming-with-python-8360",
"labels": [
"Free",
"Video"
],
"upvotes": 41
},
{
"id": 10,
"title": "A Byte of Python",
"topic": "Python",
"url": "http://www.swaroopch.com/notes/python/",
"labels": [
"Free"
],
"upvotes": 22
}
]
dineshsonachalam@macbook tech-courses-search-engine % pytest backend
=========================================== test session starts ===========================================
platform darwin -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /Users/dineshsonachalam/Desktop/tech-courses-search-engine
plugins: cov-2.12.1, metadata-1.11.0
collected 2 items
backend/tests/test_api.py .. [100%]
============================================ 2 passed in 0.35s ============================================
dineshsonachalam@macbook tech-courses-search-engine %
dineshsonachalam@macbook frontend % tree src/components
src/components
├── Nav.js
├── ResponsiveAntMenu.js
├── SearchBar.js
└── SearchResults.js
0 directories, 4 files
dineshsonachalam@macbook frontend % tree src/redux
src/redux
├── actionTypes.js
├── actions.js
├── reducers
│ ├── index.js
│ └── searchReducer.js
└── store.js
1 directory, 5 files
npm i && npm run start --prefix frontend
dineshsonachalam@macbook tech-courses-search-engine % tree frontend/cypress
frontend/cypress
├── fixtures
│ └── example.json
├── integration
│ └── search-courses.spec.js
├── plugins
│ └── index.js
└── support
├── commands.js
└── index.js
4 directories, 5 files
dineshsonachalam@macbook tech-courses-search-engine %
npx cypress open