Skip to content

Instantly share code, notes, and snippets.

@serj-p
serj-p / gist:3893320
Created October 15, 2012 16:09
ES query and mapping for failing parent/child request
{
"timeout": 180000,
"query": {
"filtered": {
"filter": {
"and": {
"filters": [
{
"term": {
"company_id": "4d07f9c8775911968cab4a80"
@serj-p
serj-p / gist:3902994
Created October 17, 2012 00:27
nodes stats
{
"cluster_name" : "..._contacts",
"nodes" : {
"I4wN75C7SMWShUGAYuIBjw" : {
"timestamp" : 1350431479249,
"name" : "Uni-Mind",
"transport_address" : "inet[/10.248.99.17:9300]",
"hostname" : "....compute.internal",
"indices" : {
"store" : {
@serj-p
serj-p / gist:3903012
Created October 17, 2012 00:31
hot_threads
This file has been truncated, but you can view the full file.
::: [Cassiopea][7mMpd-vGRGKArz6HeVshZQ][inet[/10.248.106.117:9300]]
0,0% (0s out of 2s) cpu usage by thread 'Reference Handler'
10/10 snapshots sharing following 3 elements
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
0,0% (0s out of 2s) cpu usage by thread 'Finalizer'
10/10 snapshots sharing following 4 elements
@serj-p
serj-p / gist:4047633
Created November 9, 2012 19:18
about tasks live
<14>1 2012-11-09T12:48:08.000000Z ip-10-253-0-26 contacts_rest_api 13469 MSGID13524652884394083 [default path="/mnt/nimble/src/nimble_search/nimble_search/es.py:149" role="app" service="contacts_rest_api" levelname="INFO" funcName="delay"] Task 'Index documents to ElasticSearch' ['dd9bfce7-4799-42e6-825e-2d5b02e9f216'] was sent to broker
<14>1 2012-11-09T15:04:42.000000Z ip-10-244-7-130 celeryd 22360 MSGID13524734822921806 [default path="/mnt/nimble/eggs/celery-3.0.9nimble-py2.7.egg/celery/worker/consumer.py:487" role="taskbroker" service="celeryd" levelname="INFO" funcName="on_task"] Got task from broker: Index documents to ElasticSearch[dd9bfce7-4799-42e6-825e-2d5b02e9f216]
<14>1 2012-11-09T15:05:00.000000Z ip-10-244-7-130 <string> 22375 MSGID1352473500363040 [default path="/mnt/nimble/src/nimble_search/nimble_search/es.py:136" role="taskbroker" service="<string>" levelname="INFO" funcName="retry"] Task 'Index documents to ElasticSearch' ['dd9bfce7-4799-42e6-825e-2d5b02e9f216'] was started
<14>1 2012-11-
@serj-p
serj-p / complexity of multifield mapping
Created December 18, 2013 15:55
complexity of multifield mapping
def F_DEFAULT_MULTIFIELD_MAPPING_IN_ALL(f_name):
return {
"fields": {
f_name: ANALYZED_FIELD_MAPPING_IN_ALL,
'na': NA_MAPPING
},
"type": "multi_field",
"include_in_all": True
}
@serj-p
serj-p / retry
Last active August 29, 2015 14:05
from celery.exceptions import Retry
from nimble_base.celery.api import celery
from nimble_core.search.bgtasks import ESTask
from nimble_core.search.domain import ESDocument, ESDocumentContent
from nimble_core.search.models import AsyncESCluster, ESCluster
from ntests import *
from pyes.exceptions import NoServerAvailable
from wtforms.validators import UUID
from celery.exceptions import Retry
from nimble_base.celery.api import celery
from nimble_core.search.bgtasks import ESTask
from nimble_core.search.models import AsyncESCluster, ESCluster
from ntests import *
from pyes.exceptions import NoServerAvailable
class RetryTest(object):
{
'or': [
{TerminalQ1},
{Terminalq2},
{
'and': [
{TerminalQ3}, {TerminalQ4}
]
}
]
class SavedSearchQueryPreTranslator(INSESearchQueryPreTranslator):
def __init__(self, contact_q):
"""
:param contact_q:
:type contact_q: nimble_contacts.new_search.domain.ContactsNSERequest
"""
self.contact_q = contact_q
def process_terminal(self, query):
if query.field_name == "saved_search" and query.occurence == OccurrenceTypes.IS:
diff --git a/src/nimble_contacts/nimble_contacts/rest/controllers.py b/src/nimble_contacts/nimble_contacts/rest/controllers.py
index 375ace1..a6ce793 100644
--- a/src/nimble_contacts/nimble_contacts/rest/controllers.py
+++ b/src/nimble_contacts/nimble_contacts/rest/controllers.py
@@ -2,10 +2,7 @@ import re
import math
from logging import getLogger
-from dateutil.parser import parse
-from datetime import timedelta, datetime