from project.services.elastic import Elastic
import requests
import json
from project.config import config

es = Elastic.connection()

#TODO: Some things that should be done to make these searches better is to weight
#TODO: unique words more highly. This is an option in elastic search, and it shouldn't
#TODO: be difficult to implement.

#TODO: Put all these arbitrary parameters in a search config file


class SearchResults:
    def __init__(self, data, metadata):
        self.data = data
        self.metadata = metadata


def simple_search_users(query_string, results_per_page, page):
    """
    Takes a string of space separated words to query, returns a list
    of user entities that have those keywords in any fields.
    This is to be used when filter params are not specified.
    """
    if not query_string:
        query = {
            "query": {
                "match_all": {}
            }
Ejemplo n.º 2
0
from project.services.database import Database
from project.services.elastic import Elastic
import requests
import json
from project.config import config

import models

Startups = Database['Startups']
Skills = Database['Skills']
Users = Database['Users']
connection = Database.connection()

es = Elastic.connection()


def save_entity(entity):
    """
    All database entities should pass through this method.
    This redirects all database entities to the appropriate handling
    """
    #Specific handlings
    if type(entity).__name__ == 'User':
        save_user(entity)

    elif type(entity).__name__ == 'Skill':
        save_skill(entity)

    elif type(entity).__name__ == 'Startup':
        save_startup(entity)
from project.services.elastic import Elastic
from project.services.auth import Auth
from project.services.cors import Cors
from project.services.api import API

app = Flask(__name__)

Cors.init_app(app, config)

app.config['CORS_HEADERS'] = 'Content-Type'
app.secret_key = config['SECRET_KEY']
app.debug = config['DEBUG']
app.json_encoder = CustomJSONEncoder

# Init services


Elastic.connect(config)

Auth.init_app(app, config)

API.configure(config)

API.register_blueprints(app, config)


@app.errorhandler(404)
def not_found(error=None):
    return jsonify(error='Not Found'), HTTP_404_NOT_FOUND
Ejemplo n.º 4
0
Database.connect(config)

from project.services.elastic import Elastic
from project.services.auth import Auth
from project.services.cors import Cors
from project.services.api import API

app = Flask(__name__)

Cors.init_app(app, config)

app.config['CORS_HEADERS'] = 'Content-Type'
app.secret_key = config['SECRET_KEY']
app.debug = config['DEBUG']
app.json_encoder = CustomJSONEncoder

# Init services

Elastic.connect(config)

Auth.init_app(app, config)

API.configure(config)

API.register_blueprints(app, config)


@app.errorhandler(404)
def not_found(error=None):
    return jsonify(error='Not Found'), HTTP_404_NOT_FOUND