Skip to content

Instantly share code, notes, and snippets.

View harshvb7's full-sized avatar

Harsh harshvb7

  • Cologne, Germany
View GitHub Profile
ES_CONNECTIONS = {
'default': {
'hosts': [http://localhost:9200],
}
}
ES_INDEXES = {
'default': [
('users', 'some_app.indexes.Article'),
]
import datetime
import time
from django.conf import settings
import elasticsearch_dsl as es
from elasticsearch.helpers import bulk
from elasticsearch_dsl.connections import connections
import elasticsearch_dsl as es
from some_app import abstract_index
from some_app.models import Post
class Article(abstract_index.DocumentBase):
title = es.Text(analyzer='snowball', fields={'raw': es.Keyword()})
body = es.Text(analyzer='snowball')
from datetime import datetime
from elasticsearch_dsl import Document, Date, Keyword, Text
from elasticsearch_dsl.connections import connections
# Define a default Elasticsearch client
connections.create_connection(hosts=['localhost'])
class Article(Document):
title = Text(analyzer='snowball', fields={'raw': Keyword()})
body = Text(analyzer='snowball')
from elasticsearch import Elasticsearch
client = Elasticsearch()
response = client.search(
index="my-index",
body={
"query": {
"bool": {
"must": [{"match": {"title": "python"}}],
"must_not": [{"match": {"description": "beta"}}],
{"SBALCONY":
[{
"t": "path",
"a": {"d": "M303.6,631.5c6.3,0,11.3,5.1,11.3,11.3s-5.1,11.3-11.3,11.3s-11.3-5.1-11.3-11.3S297.4,631.5,303.6,631.5z"}
},
{
"t": "path",
"a": {"d": "M332,642.8c6.3,0.6,10.8,6.1,10.3,12.2c-0.5,6.2-6.1,10.8-12.2,10.3c-6.2-0.5-10.8-6.1-10.3-12.2 C320.3,646.9,325.8,642.3,332,642.8z"}
},
{
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
class Solution(object):
def __init__(self):
self.arr = []
def add_product(self, name, locations):
self.arr.append((name, locations))
def get_locations(self):
data = {}
import datetime
import re
import urllib
from django.conf import settings
import requests
from lxml import html
from .models import Product
from django.contrib.messages.storage.fallback import FallbackStorage
from django.contrib.sessions.middleware import SessionMiddleware
from django.test import RequestFactory
class TestSomeView:
def test_view(self):
request = RequestFactory().get('/')