How can i split my raw list of tuples text formatted as each element in next row in sublimetext - sublimetext

Here what i want
screenshot
and what i have:
[('Project v1', 'aa125', 'Test', 'Gini', 0.72, 1620791363907, 'some/uri', 'TUNING', 1, 15, 'run_uuid19', None, 'xgboost_v9', None, None, 'run_uuid19', None, None, None, None, None, None, None, datetime.datetime(2021, 6, 10, 11, 50, 50, 862190), None, None, None, None, 'LIVE', None, None), ('Project v5', 'test-abc', 'Test', 'Gini', 0.93, 1620791363907, 'some/uri', 'TUNED', 5, 16, 'run_uuid20', None, 'xgboost_v10', None, None, 'run_uuid20', None, None, None, None, None, None, None, datetime.datetime(2021, 6, 10, 11, 50, 50, 862190), 11, 'FINISHED', None, None, 'LIVE', None, None), ('Project v5', 'test-abc2', 'Test', 'AUC', 0.95, 1620791363907, 'some/uri', 'TUNING', 5, 17, 'run_uuid21', None, 'xgboost_v11', None, None, 'run_uuid21', None, None, None, None, None, None, None, datetime.datetime(2021, 6, 10, 11, 50, 50, 862190), 12, 'IN_PROGRESS', None, None, 'LIVE', None, None), ('Project v5', 'test-abc3', 'Test', 'Gini', 0.81, 1620791363907, 'some/uri', 'TRAINED', 5, 18, 'run_uuid22', None, 'xgboost_v12', None, None, 'run_uuid22', None, None, None, None, None, None, None, datetime.datetime(2021, 6, 10, 11, 50, 50, 862190), 13, 'IN_PROGRESS', None, None, 'LIVE', None, None), ('Project v5', 'test-challenger', 'Test', 'AUC', 0.81, 1620791363907, 'some/uri', 'TRAINED', 5, 20, 'run_uuid24', None, 'xgboost_v19', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'LIVE', None, 18), ('Project v3', 'yeni name v3', 'Test', 'AUC', 0.84, 1620791363907, 'some/uri', 'COMPLETED', 3, 3, 'run_uuid5', None, 'xgboost', None, None, None, None, None, None, None, None, None, None, None, 1, 'FINISHED', None, None, 'LIVE', None, None), ('Project v3', 'eabcde3abc', 'Test', 'Calinski-Harabasz', 0.03, 1920791363907, 'some/uri', 'COMPLETED', 3, 10, 'run_uuid13', None, 'kmeans', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'LIVE', None, None), ('Project v3', 'eabcde', 'Test', 'AUC', 0.87, 1622761363907, 'some/uri', 'TRAINED', 3, 6, 'run_uuid8', None, 'xgboost', None, None, None, None, None, None, None, None, None, None, None, 8, 'FAILED', None, None, 'LIVE', None, None), ('Project v3', 'abcd', 'Test', 'AUC', 0.86, 1621761363907, 'some/uri', 'TUNING', 3, 5, 'run_uuid7', None, 'xgboost', None, None, None, None, None, None, None, None, None, None, None, 3, 'FINISHED', None, None, 'LIVE', None, None), ('Project v2', 'exp123', 'Test', 'AUC', 0.87, 1620791363907, 'some/uri', 'TRAINED', 2, 13, 'run_uuid16', None, 'xgboost', 1, 2, 'run_uuid16', None, None, None, None, None, None, None, datetime.datetime(2021, 6, 10, 11, 50, 50, 862190), None, None, 'SME', 'Legal Recovery', 'LIVE', 'Legal Recovery', None), ('Project v1', 'aa124', 'Test', 'Gini', 0.22, 1620791363907, 'some/uri', 'TUNED', 1, 14, 'run_uuid17', None, 'xgboost_v6', None, None, 'run_uuid17', None, None, None, None, None, None, None, datetime.datetime(2021, 6, 10, 11, 50, 50, 862190), None, None, None, None, 'LIVE', None, None), ('Project v1', 'aa124', 'Test', 'Gini', 0.22, 1620791363907, 'some/uri', 'TUNED', 1, 14, 'run_uuid18', None, 'tuned_random_forest_21:03:07', None, None, 'run_uuid18', None, None, None, None, None, None, None, datetime.datetime(2021, 6, 10, 11, 50, 50, 862190), None, None, None, None, 'LIVE', None, None), ('Project v3', 'abc', 'Test', 'AUC', 0.85, 1620781363907, 'some/uri', 'TUNED', 3, 4, 'run_uuid6', None, 'xgboost', None, None, 'run_uuid6', 'FAIL', 'token_2', 's3://mlflow/4/run_uuid6/artifacts/audit.csv', datetime.datetime(2021, 5, 23, 9, 16, 3, 907000), 'audit notes for model run_uuid6', 'test', datetime.datetime(2021, 5, 24, 9, 18, 3, 907000), None, 5, 'IN_PROGRESS', None, None, 'LIVE', None, None), ('Project v2', 'yeni name v2', 'Test', 'AUC', 0.76, 1620761373907, 'some/uri', 'TRAINED', 2, 2, 'run_uuid4', None, 'logistic_regression', 1, 2, 'run_uuid4', 'PASS', 'token_1', 's3://mlflow/2/run_uuid4/artifacts/audit.csv', datetime.datetime(2021, 5, 24, 9, 18, 3, 907000), None, 'test', datetime.datetime(2021, 5, 24, 9, 18, 3, 907000), None, None, None, 'SME', 'Legal Recovery', 'LIVE', 'Legal Recovery', None), ('Project v4', 'exp cm', 'Test', 'AUC', 0.81, 1620791373907, 'some/uri', 'TRAINED', 4, 19, 'run_uuid37', None, 'mlp', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'CUSTOM', 'Collections', None), ('Project v4', 'exp cm', 'Test', 'AUC', 0.81, 1620791363907, 'some/uri', 'TRAINED', 4, 19, 'run_uuid25', None, 'keras', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'CUSTOM', 'Collections', None), ('Project v4', 'exp cm', 'Test', 'AUC', 0.81, 1620791363907, 'some/uri', 'TRAINED', 4, 19, 'run_uuid26', None, 'light_gbm', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'CUSTOM', 'Collections', None), ('Project v4', 'exp cm', 'Test', 'AUC', 0.81, 1620791363907, 'some/uri', 'TRAINED', 4, 19, 'run_uuid28', None, 'decision_tree', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'CUSTOM', 'Collections', None), ('Project v4', 'exp cm', 'Test', 'AUC', 0.81, 1620791363907, 'some/uri', 'TRAINED', 4, 19, 'run_uuid29', None, 'lasso', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'CUSTOM', 'Collections', None), ('Project v4', 'exp cm', 'Test', 'AUC', 0.81, 1620791363907, 'some/uri', 'TRAINED', 4, 19, 'run_uuid30', None, 'lars', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'CUSTOM', 'Collections', None), ('Project v4', 'exp cm', 'Test', 'AUC', 0.81, 1620791363907, 'some/uri', 'TRAINED', 4, 19, 'run_uuid31', None, 'ridge', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'CUSTOM', 'Collections', None), ('Project v4', 'exp cm', 'Test', 'AUC', 0.81, 1620791363907, 'some/uri', 'TRAINED', 4, 19, 'run_uuid32', None, 'kernel_ridge', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'CUSTOM', 'Collections', None), ('Project v4', 'exp cm', 'Test', 'AUC', 0.81, 1620791363907, 'some/uri', 'TRAINED', 4, 19, 'run_uuid33', None, 'sgd', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'CUSTOM', 'Collections', None), ('Project v4', 'exp cm', 'Test', 'AUC', 0.81, 1620791363907, 'some/uri', 'TRAINED', 4, 19, 'run_uuid34', None, 'svc', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'CUSTOM', 'Collections', None), ('Project v4', 'exp cm', 'Test', 'AUC', 0.81, 1620791363907, 'some/uri', 'TRAINED', 4, 19, 'run_uuid35', None, 'k_neighbors_classifier', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'CUSTOM', 'Collections', None), ('Project v4', 'exp cm', 'Test', 'AUC', 0.81, 1620791363907, 'some/uri', 'TRAINED', 4, 19, 'run_uuid36', None, 'tensorflow', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'CUSTOM', 'Collections', None), ('Project v1', 'experiment name v1', 'Test', 'AUC', 0.8, 1620721363921, 'some/uri', 'COMPLETED', 1, 1, 'run_uuid1', 'mock_url', 'random_forest', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'LIVE', None, None), ('Project v1', 'experiment name v1', 'Test', 'AUC', 0.81, 1620721363131, 'some/uri', 'COMPLETED', 1, 1, 'run_uuid2', 'mock_url', 'xgboost', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'LIVE', None, None), ('Project v4', 'exp cls', 'Test', 'AUC', 0.74, 1620721313930, 'some/uri', 'TRAINED', 4, 11, 'run_uuid14', None, 'xgboost', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'LIVE', 'Collections', None), ('Project v2', 'exp reg', 'Test', 'MAPE', 0.85, 1620721313930, 'some/uri', 'TRAINED', 2, 12, 'run_uuid15', None, 'xgboost', 1, 2, None, None, None, None, None, None, None, None, None, None, None, 'SME', 'Legal Recovery', 'LIVE', 'Legal Recovery', None), ('Project v4', 'exp cm', 'Test', 'AUC', 0.74, 1620721313930, 'some/uri', 'TRAINED', 4, 19, 'run_uuid23', None, 'xgboost', 3, 4, None, None, None, None, None, None, None, None, None, None, None, 'Retail', 'Collections', 'CUSTOM', 'Collections', None), ('Project v1', 'experiment name v1', 'Test', 'AUC', 0.82, 1620721313930, 'some/uri', 'COMPLETED', 1, 1, 'run_uuid3', 'mock_url', 'logistic_regression', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'LIVE', None, None)]
i want to start each line with each element if my list has 18 elements it must be 18 elements

For this set of data, formatting the way you want is quite easy.
Open Find → Replace….
In the Find field, enter (\('Project).
In the Replace field, enter \n$1.
Make sure the "Regular Expression" and "Wrap" buttons are selected.
Hit the Replace All button.
and you should be all set. You will have to put the final closing bracket ] on its own line manually.

Related

serialization of nested JSON in Django

class GrossenSerializer(serializers.Serializer):
artikelNr1 = serializers.IntegerField()
artikelNr2 = serializers.IntegerField()
artikelGr = serializers.IntegerField()
groessenText = serializers.CharField()
sku = serializers.CharField()
istZl = serializers.IntegerField()
verkPeriode = serializers.IntegerField()
def validate(self, attrs):
return super(GrossenSerializer, self).validate(attrs)
class CategoriesRootsSerializer(serializers.Serializer):
id = serializers.IntegerField()
name = serializers.CharField()
parentCategoryId = serializers.IntegerField()
def validate(self, attrs):
return super(CategoriesRootsSerializer, self).validate(attrs)
class CategoriesSerializer(serializers.Serializer):
id=serializers.IntegerField()
name=serializers.CharField(max_length=50)
parentCategoryId=serializers.IntegerField()
categoryRoots = serializers.ListField(child=CategoriesRootsSerializer(many=True, read_only=True))
def validate(self, attrs):
return super(CategoriesSerializer, self).validate(attrs)
sku=serializers.CharField(max_length=50, allow_blank=True)
artikelNr1=serializers.IntegerField()
artikelNr2=serializers.IntegerField()
StatusCode=serializers.IntegerField(required=False)
statusText=serializers.CharField(max_length=50, allow_blank=True)
SaisonRetourenCode=serializers.IntegerField(required=False)
saisonRetourenText=serializers.CharField(max_length=50, allow_blank=True)
saisonCode=serializers.IntegerField()
saisonText=serializers.CharField(max_length=50, allow_blank=True)
geschlechtCode=serializers.IntegerField()
geschlechtText=serializers.CharField(max_length=50, allow_blank=True)
RayonCode=serializers.IntegerField(required=False)
rayonText=serializers.CharField(max_length=50)
warenArtCode=serializers.IntegerField()
warenArtText=serializers.CharField(max_length=50)
wuCode=serializers.IntegerField()
wuText=serializers.CharField(max_length=50)
waCode=serializers.IntegerField()
warenGruppe=serializers.CharField(max_length=50, allow_blank=True)
alterCode=serializers.IntegerField()
farbe=serializers.CharField(max_length=50)
material=serializers.CharField(max_length=50)
bezeichnung=serializers.CharField(max_length=50)
pictureName=serializers.CharField(max_length=50)
picturePathLocal=serializers.CharField(max_length=50)
kollektion=serializers.CharField(max_length=50, allow_blank=True)
comCode=serializers.CharField(max_length=50)
lieferant=serializers.CharField(max_length=50)
eKchf=serializers.FloatField()
eti=serializers.FloatField()
vp=serializers.FloatField()
groessenCode=serializers.IntegerField()
groessen=GrossenSerializer(many=True, read_only=True)
zlQty=serializers.IntegerField()
productId=serializers.IntegerField()
published=serializers.BooleanField()
categories=CategoriesSerializer(many=True, read_only=True)
productName=serializers.CharField(max_length=50)
shortDescription=serializers.CharField(max_length=150)
fullDescription=serializers.CharField()
flag=serializers.CharField(allow_blank=True)
def validate(self, attrs):
return super(RecommendationJsonSerializer, self).validate(attrs)
in a view i am calling it through Get method like so
if request.method == 'GET':
for json in jsonList:
data = json
data['author'] = request.user.pk
serializer = RecommendationJsonSerializer(data=data)
data = {}
print(serializer.is_valid())
if serializer.is_valid():
print(serializer.error_messages)
return Response(data=data)
i am getting this error
{'required': 'This field is required.', 'null': 'This field may not be null.', 'invalid': 'Invalid data. Expected a dictionary, but got {datatype}.'}
my input JSON which I am trying to serialize
{'artikelNr1': 133198, 'artikelNr2': 0, 'sku': '133198.00', 'statusCode': 4, 'statusText': 'Manuell Bewirtschaftung', 'saisonRetourenCode': 0, 'saisonRetourenText': 'unbestimmt', 'saisonCode': 0, 'saisonText': 'SAISON', 'geschlechtCode': 1, 'geschlechtText': 'UNISEX', 'rayonCode': 0, 'rayonText': '<RAYON>', 'warenArtCode': 6600, 'warenArtText': 'ACCESSOIRES/DIV.', 'wuCode': 66, 'wuText': 'ACCESSOIRES/DIV.', 'waCode': 6, 'warenGruppe': 'DESSOUS', 'alterCode': 20164, 'farbe': 'BLACK', 'material': 'PLASTIC', 'bezeichnung': "'METRO BOUTIQUE GIFTCARD' CHF20", 'pictureName': 'art_133198_00.jpg', 'picturePathLocal': 'p:\\', 'kollektion': '', 'comCode': 'METRO BOUTIQUE GESCHENKKARTE CHF 20', 'lieferant': '...', 'eKchf': 0, 'eti': 20, 'vp': 20, 'groessenCode': 0, 'groessen': [{'artikelNr1': 133198, 'artikelNr2': 0, 'artikelGr': 1, 'groessenText': 'os', 'sku': '133198.00.01', 'istZl': 463, 'verkPeriode': -268}], 'zlQty': 463, 'productId': 82482, 'published': True, 'categories': [{'categoryRoots': [{'id': 1, 'name': 'Damen', 'parentCategoryId': 0}, {'id': 188, 'name': 'Geschenkkarten', 'parentCategoryId': 1}], 'id': 188, 'name': 'Geschenkkarten', 'parentCategoryId': 1}, {'categoryRoots': [{'id': 2, 'name': 'Herren', 'parentCategoryId': 0}, {'id': 186, 'name': 'Geschenkkarten', 'parentCategoryId': 2}], 'id': 186, 'name': 'Geschenkkarten', 'parentCategoryId': 2}, {'categoryRoots': [{'id': 3, 'name': 'Mädchen', 'parentCategoryId': 0}, {'id': 183, 'name': 'Geschenkkarten', 'parentCategoryId': 3}], 'id': 183, 'name': 'Geschenkkarten', 'parentCategoryId': 3}, {'categoryRoots': [{'id': 4, 'name': 'Jungen', 'parentCategoryId': 0}, {'id': 180, 'name': 'Geschenkkarten', 'parentCategoryId': 4}], 'id': 180, 'name': 'Geschenkkarten', 'parentCategoryId': 4}, {'categoryRoots': [{'id': 1, 'name': 'Damen', 'parentCategoryId': 0}, {'id': 376, 'name': 'Bekleidung', 'parentCategoryId': 1}, {'id': 21, 'name': 'Fanshop', 'parentCategoryId': 376}], 'id': 21, 'name': 'Fanshop', 'parentCategoryId': 376}, {'categoryRoots': [{'id': 2, 'name': 'Herren', 'parentCategoryId': 0}, {'id': 411, 'name': 'Bekleidung', 'parentCategoryId': 2}, {'id': 32, 'name': 'Fanshop', 'parentCategoryId': 411}], 'id': 32, 'name': 'Fanshop', 'parentCategoryId': 411}], 'productName': 'Giftcard', 'shortDescription': 'Giftcard - Schwarz + Gelb', 'fullDescription': "<p>Metro Geschenkkarte - die perfekte Geschenkidee für alle Gelegenheiten<br />Dient als komfortables Zahlungsmittel in sämtlichen Metro Boutique Filialen und in unserem Online-Shop<br />Die Geschenkkarte kann in jeder Filiale aufgeladen werden<br /><span style='color:red'><span style='color:red'>Nicht retournierbar!</span></span></p>", 'flag': '', 'author': 1}
this is my input JSON which I am trying to give to this serializer is anybody has some idea what I am doing wrong...

Why DSL is giving score of 1.0 for query string search

I have data inside one index
Below is the first 3 documents, I have 111 documents. I am paring first 3 only
q = {"size":3,"query":{ "match_all":{}}}
{'took': 1, 'timed_out': False, '_shards': {'total': 1, 'successful': 1, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 111, 'relation': 'eq'}, 'max_score': 1.0, 'hits': [{'_index': 'movie_data_01_03', '_type': '_doc', '_id': '0', '_score': 1.0, '_source': {'id': 0, 'Title': 'The Land Girls', 'US Gross': 146083, 'Worldwide Gross': 146083, 'US DVD Sales': None, 'Production Budget': 8000000, 'Release Date': 'Jun 12 1998', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Gramercy', 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.1, 'IMDB Votes': 1071}}, {'_index': 'movie_data_01_03', '_type': '_doc', '_id': '1', '_score': 1.0, '_source': {'id': 1, 'Title': 'First Love, Last Rites', 'US Gross': 10876, 'Worldwide Gross': 10876, 'US DVD Sales': None, 'Production Budget': 300000, 'Release Date': 'Aug 07 1998', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Strand', 'Source': None, 'Major Genre': 'Drama', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.9, 'IMDB Votes': 207}}, {'_index': 'movie_data_01_03', '_type': '_doc', '_id': '2', '_score': 1.0, '_source': {'id': 2, 'Title': 'I Married a Strange Person', 'US Gross': 203134, 'Worldwide Gross': 203134, 'US DVD Sales': None, 'Production Budget': 250000, 'Release Date': 'Aug 28 1998', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'Lionsgate', 'Source': None, 'Major Genre': 'Comedy', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.8, 'IMDB Votes': 865}}]}}
Below query is giving _score of 1.0 for every document? why
I am searching Live in elasticsearch
query = {'from': 0, 'size': 30, 'query': {'bool': {'must': {'query_string': {'query': '**Live**'}}}}}
My Output is below
{'took': 23, 'timed_out': False, '_shards': {'total': 1, 'successful': 1, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 3, 'relation': 'eq'}, 'max_score': 1.0, 'hits': [{'_index': 'movie_data_01_03', '_type': '_doc', '_id': '11', '_score': 1.0, '_source': {'id': 11, 'Title': 'Oliver!', 'US Gross': 37402877, 'Worldwide Gross': 37402877, 'US DVD Sales': None, 'Production Budget': 10000000, 'Release Date': 'Dec 11 1968', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'Sony Pictures', 'Source': None, 'Major Genre': 'Musical', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': 84, 'IMDB Rating': 7.5, 'IMDB Votes': 9111}}, {'_index': 'movie_data_01_03', '_type': '_doc', '_id': '52', '_score': 1.0, '_source': {'id': 52, 'Title': 'Alive', 'US Gross': 36299670, 'Worldwide Gross': 36299670, 'US DVD Sales': None, 'Production Budget': 32000000, 'Release Date': 'Jan 15 1993', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Walt Disney Pictures', 'Source': 'Based on Book/Short Story', 'Major Genre': 'Adventure', 'Creative Type': 'Dramatization', 'Director': 'Frank Marshall', 'Rotten Tomatoes Rating': 71, 'IMDB Rating': 3.2, 'IMDB Votes': 124}}, {'_index': 'movie_data_01_03', '_type': '_doc', '_id': '90', '_score': 1.0, '_source': {'id': 90, 'Title': 'The Best Years of Our Lives', 'US Gross': 23600000, 'Worldwide Gross': 23600000, 'US DVD Sales': None, 'Production Budget': 2100000, 'Release Date': 'Nov 21 2046', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'RKO Radio Pictures', 'Source': 'Based on Book/Short Story', 'Major Genre': 'Drama', 'Creative Type': None, 'Director': 'William Wyler', 'Rotten Tomatoes Rating': 97, 'IMDB Rating': 8.2, 'IMDB Votes': 17338}}]}}
When you are searching for **Live** (i.e doing a wildcard search), in this by default a constant score is applied, due to which you are getting score of 1.0
You need to add rewrite parameter, that will determine how the relevance score is calculated. Modify your search query as
{
"from": 0,
"size": 30,
"query": {
"bool": {
"must": {
"query_string": {
"query": "**live**",
"rewrite": "scoring_boolean"
}
}
}
}
}
Search Result will be
"hits": [
{
"_index": "66684902",
"_type": "_doc",
"_id": "1",
"_score": 1.3177552,
"_source": {
"id": 11,
"Title": "Oliver!",
"US Gross": 37402877,
"Worldwide Gross": 37402877,
"US DVD Sales": "None",
"Production Budget": 10000000,
"Release Date": "Dec 11 1968",
"MPAA Rating": "None",
"Running Time min": "None",
"Distributor": "Sony Pictures",
"Source": "None",
"Major Genre": "Musical",
"Creative Type": "None",
"Director": "None",
"Rotten Tomatoes Rating": 84,
"IMDB Rating": 7.5,
"IMDB Votes": 9111
}
},
{
"_index": "66684902",
"_type": "_doc",
"_id": "2",
"_score": 1.3177552,
"_source": {
"id": 52,
"Title": "Alive",
"US Gross": 36299670,
"Worldwide Gross": 36299670,
"US DVD Sales": "None",
"Production Budget": 32000000,
"Release Date": "Jan 15 1993",
"MPAA Rating": "R",
"Running Time min": "None",
"Distributor": "Walt Disney Pictures",
"Source": "Based on Book/Short Story",
"Major Genre": "Adventure",
"Creative Type": "Dramatization",
"Director": "Frank Marshall",
"Rotten Tomatoes Rating": 71,
"IMDB Rating": 3.2,
"IMDB Votes": 124
}
},
{
"_index": "66684902",
"_type": "_doc",
"_id": "3",
"_score": 0.64896965,
"_source": {
"id": 90,
"Title": "The Best Years of Our Lives",
"US Gross": 23600000,
"Worldwide Gross": 23600000,
"US DVD Sales": "None",
"Production Budget": 2100000,
"Release Date": "Nov 21 2046",
"MPAA Rating": "None",
"Running Time min": "None",
"Distributor": "RKO Radio Pictures",
"Source": "Based on Book/Short Story",
"Major Genre": "Drama",
"Creative Type": "None",
"Director": "William Wyler",
"Rotten Tomatoes Rating": 97,
"IMDB Rating": 8.2,
"IMDB Votes": 17338
}
}
]

How to add fuzziness for normal search query

Query is below
{"from": 0, "size": 1000, "query": {"bool": {"must": {"query_string": {"query": "Love"}}}}}
If I pass Live also then also i need to get search results for Love
Mapping
{'movie_data': {'mappings': {'properties': {'Creative Type': {'type': 'text', 'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}}, 'Director': {'type': 'text', 'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}}, 'Distributor': {'type': 'text', 'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}}, 'IMDB Rating': {'type': 'float'}, 'IMDB Votes': {'type': 'long'}, 'MPAA Rating': {'type': 'text', 'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}}, 'Major Genre': {'type': 'text', 'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}}, 'Production Budget': {'type': 'long'}, 'Release Date': {'type': 'text', 'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}}, 'Rotten Tomatoes Rating': {'type': 'text', 'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}}, 'Running Time min': {'type': 'text', 'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}}, 'Source': {'type': 'text', 'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}}, 'Title': {'type': 'text', 'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}}, 'US DVD Sales': {'type': 'text', 'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}}, 'US Gross': {'type': 'long'}, 'Worldwide Gross': {'type': 'long'}, 'id': {'type': 'long'}}}}}
match_all query result is below
{'took': 8, 'timed_out': False, '_shards': {'total': 1, 'successful': 1, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 30, 'relation': 'eq'}, 'max_score': 1.0, 'hits': [{'_index': 'new_index', '_type': '_doc', '_id': '0', '_score': 1.0, '_source': {'id': 0, 'Title': 'The Land Girls', 'US Gross': 146083, 'Worldwide Gross': 146083, 'US DVD Sales': None, 'Production Budget': 8000000, 'Release Date': 'Jun 12 1998', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Gramercy', 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.1, 'IMDB Votes': 1071}}, {'_index': 'new_index', '_type': '_doc', '_id': '1', '_score': 1.0, '_source': {'id': 1, 'Title': 'First Love, Last Rites', 'US Gross': 10876, 'Worldwide Gross': 10876, 'US DVD Sales': None, 'Production Budget': 300000, 'Release Date': 'Aug 07 1998', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Strand', 'Source': None, 'Major Genre': 'Drama', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.9, 'IMDB Votes': 207}}, {'_index': 'new_index', '_type': '_doc', '_id': '2', '_score': 1.0, '_source': {'id': 2, 'Title': 'I Married a Strange Person', 'US Gross': 203134, 'Worldwide Gross': 203134, 'US DVD Sales': None, 'Production Budget': 250000, 'Release Date': 'Aug 28 1998', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'Lionsgate', 'Source': None, 'Major Genre': 'Comedy', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.8, 'IMDB Votes': 865}}, {'_index': 'new_index', '_type': '_doc', '_id': '3', '_score': 1.0, '_source': {'id': 3, 'Title': "Let's Talk About Sex", 'US Gross': 373615, 'Worldwide Gross': 373615, 'US DVD Sales': None, 'Production Budget': 300000, 'Release Date': 'Sep 11 1998', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'Fine Line', 'Source': None, 'Major Genre': 'Comedy', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': 13, 'IMDB Rating': None, 'IMDB Votes': None}}, {'_index': 'new_index', '_type': '_doc', '_id': '4', '_score': 1.0, '_source': {'id': 4, 'Title': 'Slam', 'US Gross': 1009819, 'Worldwide Gross': 1087521, 'US DVD Sales': None, 'Production Budget': 1000000, 'Release Date': 'Oct 09 1998', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Trimark', 'Source': 'Original Screenplay', 'Major Genre': 'Drama', 'Creative Type': 'Contemporary Fiction', 'Director': None, 'Rotten Tomatoes Rating': 62, 'IMDB Rating': 3.4, 'IMDB Votes': 165}}, {'_index': 'new_index', '_type': '_doc', '_id': '5', '_score': 1.0, '_source': {'id': 5, 'Title': 'Mississippi Mermaid', 'US Gross': 24551, 'Worldwide Gross': 2624551, 'US DVD Sales': None, 'Production Budget': 1600000, 'Release Date': 'Jan 15 1999', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'MGM', 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': None, 'IMDB Votes': None}}, {'_index': 'new_index', '_type': '_doc', '_id': '6', '_score': 1.0, '_source': {'id': 6, 'Title': 'Following', 'US Gross': 44705, 'Worldwide Gross': 44705, 'US DVD Sales': None, 'Production Budget': 6000, 'Release Date': 'Apr 04 1999', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Zeitgeist', 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': 'Christopher Nolan', 'Rotten Tomatoes Rating': None, 'IMDB Rating': 7.7, 'IMDB Votes': 15133}}, {'_index': 'new_index', '_type': '_doc', '_id': '7', '_score': 1.0, '_source': {'id': 7, 'Title': 'Foolish', 'US Gross': 6026908, 'Worldwide Gross': 6026908, 'US DVD Sales': None, 'Production Budget': 1600000, 'Release Date': 'Apr 09 1999', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Artisan', 'Source': 'Original Screenplay', 'Major Genre': 'Comedy', 'Creative Type': 'Contemporary Fiction', 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 3.8, 'IMDB Votes': 353}}, {'_index': 'new_index', '_type': '_doc', '_id': '8', '_score': 1.0, '_source': {'id': 8, 'Title': 'Pirates', 'US Gross': 1641825, 'Worldwide Gross': 6341825, 'US DVD Sales': None, 'Production Budget': 40000000, 'Release Date': 'Jul 01 1986', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': None, 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': 'Roman Polanski', 'Rotten Tomatoes Rating': 25, 'IMDB Rating': 5.8, 'IMDB Votes': 3275}}, {'_index': 'new_index', '_type': '_doc', '_id': '9', '_score': 1.0, '_source': {'id': 9, 'Title': 'Duel in the Sun', 'US Gross': 20400000, 'Worldwide Gross': 20400000, 'US DVD Sales': None, 'Production Budget': 6000000, 'Release Date': 'Dec 31 2046', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': None, 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': 86, 'IMDB Rating': 7, 'IMDB Votes': 2906}}, {'_index': 'new_index', '_type': '_doc', '_id': '10', '_score': 1.0, '_source': {'id': 10, 'Title': 'Tom Jones', 'US Gross': 37600000, 'Worldwide Gross': 37600000, 'US DVD Sales': None, 'Production Budget': 1000000, 'Release Date': 'Oct 07 1963', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': None, 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': 81, 'IMDB Rating': 7, 'IMDB Votes': 4035}}, {'_index': 'new_index', '_type': '_doc', '_id': '11', '_score': 1.0, '_source': {'id': 11, 'Title': 'Oliver!', 'US Gross': 37402877, 'Worldwide Gross': 37402877, 'US DVD Sales': None, 'Production Budget': 10000000, 'Release Date': 'Dec 11 1968', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'Sony Pictures', 'Source': None, 'Major Genre': 'Musical', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': 84, 'IMDB Rating': 7.5, 'IMDB Votes': 9111}}, {'_index': 'new_index', '_type': '_doc', '_id': '12', '_score': 1.0, '_source': {'id': 12, 'Title': 'To Kill A Mockingbird', 'US Gross': 13129846, 'Worldwide Gross': 13129846, 'US DVD Sales': None, 'Production Budget': 2000000, 'Release Date': 'Dec 25 1962', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'Universal', 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': 97, 'IMDB Rating': 8.4, 'IMDB Votes': 82786}}, {'_index': 'new_index', '_type': '_doc', '_id': '13', '_score': 1.0, '_source': {'id': 13, 'Title': 'Tora, Tora, Tora', 'US Gross': 29548291, 'Worldwide Gross': 29548291, 'US DVD Sales': None, 'Production Budget': 25000000, 'Release Date': 'Sep 23 1970', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': None, 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': 'Richard Fleischer', 'Rotten Tomatoes Rating': None, 'IMDB Rating': None, 'IMDB Votes': None}}, {'_index': 'new_index', '_type': '_doc', '_id': '14', '_score': 1.0, '_source': {'id': 14, 'Title': 'Hollywood Shuffle', 'US Gross': 5228617, 'Worldwide Gross': 5228617, 'US DVD Sales': None, 'Production Budget': 100000, 'Release Date': 'Mar 01 1987', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': None, 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': 87, 'IMDB Rating': 6.8, 'IMDB Votes': 1532}}, {'_index': 'new_index', '_type': '_doc', '_id': '15', '_score': 1.0, '_source': {'id': 15, 'Title': 'Over the Hill to the Poorhouse', 'US Gross': 3000000, 'Worldwide Gross': 3000000, 'US DVD Sales': None, 'Production Budget': 100000, 'Release Date': 'Sep 17 2020', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': None, 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': None, 'IMDB Votes': None}}, {'_index': 'new_index', '_type': '_doc', '_id': '16', '_score': 1.0, '_source': {'id': 16, 'Title': 'Wilson', 'US Gross': 2000000, 'Worldwide Gross': 2000000, 'US DVD Sales': None, 'Production Budget': 5200000, 'Release Date': 'Aug 01 2044', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': None, 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 7, 'IMDB Votes': 451}}, {'_index': 'new_index', '_type': '_doc', '_id': '17', '_score': 1.0, '_source': {'id': 17, 'Title': 'Darling Lili', 'US Gross': 5000000, 'Worldwide Gross': 5000000, 'US DVD Sales': None, 'Production Budget': 22000000, 'Release Date': 'Jan 01 1970', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': None, 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': 'Blake Edwards', 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.1, 'IMDB Votes': 858}}, {'_index': 'new_index', '_type': '_doc', '_id': '18', '_score': 1.0, '_source': {'id': 18, 'Title': 'The Ten Commandments', 'US Gross': 80000000, 'Worldwide Gross': 80000000, 'US DVD Sales': None, 'Production Budget': 13500000, 'Release Date': 'Oct 05 1956', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': None, 'Source': None, 'Major Genre': None, 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': 90, 'IMDB Rating': 2.5, 'IMDB Votes': 1677}}, {'_index': 'new_index', '_type': '_doc', '_id': '19', '_score': 1.0, '_source': {'id': 19, 'Title': '12 Angry Men', 'US Gross': 0, 'Worldwide Gross': 0, 'US DVD Sales': None, 'Production Budget': 340000, 'Release Date': 'Apr 13 1957', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'United Artists', 'Source': 'Original Screenplay', 'Major Genre': 'Drama', 'Creative Type': None, 'Director': 'Sidney Lumet', 'Rotten Tomatoes Rating': None, 'IMDB Rating': 8.9, 'IMDB Votes': 119101}}, {'_index': 'new_index', '_type': '_doc', '_id': '20', '_score': 1.0, '_source': {'id': 20, 'Title': 'Twelve Monkeys', 'US Gross': 57141459, 'Worldwide Gross': 168841459, 'US DVD Sales': None, 'Production Budget': 29000000, 'Release Date': 'Dec 27 1995', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Universal', 'Source': 'Based on Short Film', 'Major Genre': 'Drama', 'Creative Type': 'Science Fiction', 'Director': 'Terry Gilliam', 'Rotten Tomatoes Rating': None, 'IMDB Rating': 8.1, 'IMDB Votes': 169858}}, {'_index': 'new_index', '_type': '_doc', '_id': '21', '_score': 1.0, '_source': {'id': 21, 'Title': 1776, 'US Gross': 0, 'Worldwide Gross': 0, 'US DVD Sales': None, 'Production Budget': 4000000, 'Release Date': 'Nov 09 1972', 'MPAA Rating': 'PG', 'Running Time min': None, 'Distributor': 'Sony/Columbia', 'Source': 'Based on Play', 'Major Genre': 'Drama', 'Creative Type': 'Historical Fiction', 'Director': None, 'Rotten Tomatoes Rating': 57, 'IMDB Rating': 7, 'IMDB Votes': 4099}}, {'_index': 'new_index', '_type': '_doc', '_id': '22', '_score': 1.0, '_source': {'id': 22, 'Title': 1941, 'US Gross': 34175000, 'Worldwide Gross': 94875000, 'US DVD Sales': None, 'Production Budget': 32000000, 'Release Date': 'Dec 14 1979', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'Universal', 'Source': 'Original Screenplay', 'Major Genre': 'Comedy', 'Creative Type': 'Historical Fiction', 'Director': 'Steven Spielberg', 'Rotten Tomatoes Rating': 33, 'IMDB Rating': 5.6, 'IMDB Votes': 13364}}, {'_index': 'new_index', '_type': '_doc', '_id': '23', '_score': 1.0, '_source': {'id': 23, 'Title': 'Chacun sa nuit', 'US Gross': 18435, 'Worldwide Gross': 18435, 'US DVD Sales': None, 'Production Budget': 1900000, 'Release Date': 'Jun 29 2007', 'MPAA Rating': 'Not Rated', 'Running Time min': None, 'Distributor': 'Strand', 'Source': 'Original Screenplay', 'Major Genre': 'Thriller/Suspense', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.3, 'IMDB Votes': 365}}, {'_index': 'new_index', '_type': '_doc', '_id': '24', '_score': 1.0, '_source': {'id': 24, 'Title': '2001: A Space Odyssey', 'US Gross': 56700000, 'Worldwide Gross': 68700000, 'US DVD Sales': None, 'Production Budget': 10500000, 'Release Date': 'Apr 02 1968', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': None, 'Source': 'Original Screenplay', 'Major Genre': None, 'Creative Type': 'Science Fiction', 'Director': 'Stanley Kubrick', 'Rotten Tomatoes Rating': 96, 'IMDB Rating': 8.4, 'IMDB Votes': 160342}}, {'_index': 'new_index', '_type': '_doc', '_id': '25', '_score': 1.0, '_source': {'id': 25, 'Title': '20,000 Leagues Under the Sea', 'US Gross': 28200000, 'Worldwide Gross': 28200000, 'US DVD Sales': None, 'Production Budget': 5000000, 'Release Date': 'Dec 23 1954', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': 'Walt Disney Pictures', 'Source': 'Based on Book/Short Story', 'Major Genre': 'Adventure', 'Creative Type': None, 'Director': 'Richard Fleischer', 'Rotten Tomatoes Rating': 92, 'IMDB Rating': None, 'IMDB Votes': None}}, {'_index': 'new_index', '_type': '_doc', '_id': '26', '_score': 1.0, '_source': {'id': 26, 'Title': '20,000 Leagues Under the Sea', 'US Gross': 8000000, 'Worldwide Gross': 8000000, 'US DVD Sales': None, 'Production Budget': 200000, 'Release Date': 'Dec 24 2016', 'MPAA Rating': None, 'Running Time min': None, 'Distributor': None, 'Source': 'Based on Book/Short Story', 'Major Genre': 'Adventure', 'Creative Type': None, 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': None, 'IMDB Votes': None}}, {'_index': 'new_index', '_type': '_doc', '_id': '27', '_score': 1.0, '_source': {'id': 27, 'Title': '24 7: Twenty Four Seven', 'US Gross': 72544, 'Worldwide Gross': 72544, 'US DVD Sales': None, 'Production Budget': 2000000, 'Release Date': 'Apr 15 1998', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'October Films', 'Source': 'Original Screenplay', 'Major Genre': 'Comedy', 'Creative Type': None, 'Director': 'Shane Meadows', 'Rotten Tomatoes Rating': None, 'IMDB Rating': 6.9, 'IMDB Votes': 1417}}, {'_index': 'new_index', '_type': '_doc', '_id': '28', '_score': 1.0, '_source': {'id': 28, 'Title': 'Twin Falls Idaho', 'US Gross': 985341, 'Worldwide Gross': 1027228, 'US DVD Sales': None, 'Production Budget': 500000, 'Release Date': 'Jul 30 1999', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': 'Sony Pictures Classics', 'Source': 'Original Screenplay', 'Major Genre': 'Drama', 'Creative Type': 'Contemporary Fiction', 'Director': 'Michael Polish', 'Rotten Tomatoes Rating': 77, 'IMDB Rating': 7.1, 'IMDB Votes': 2810}}, {'_index': 'new_index', '_type': '_doc', '_id': '29', '_score': 1.0, '_source': {'id': 29, 'Title': 'Three Kingdoms: Resurrection of the Dragon', 'US Gross': 0, 'Worldwide Gross': 22139590, 'US DVD Sales': None, 'Production Budget': 20000000, 'Release Date': 'Apr 03 2008', 'MPAA Rating': 'R', 'Running Time min': None, 'Distributor': None, 'Source': 'Based on Book/Short Story', 'Major Genre': 'Action', 'Creative Type': 'Historical Fiction', 'Director': None, 'Rotten Tomatoes Rating': None, 'IMDB Rating': None, 'IMDB Votes': None}}]}}
For query string, you need to explicitly use the ~operator. Try out the below query
{
"from": 0,
"size": 1000,
"query": {
"bool": {
"must": {
"query_string": {
"query": "live~", // note this
"fuzziness": "auto"
}
}
}
}
}
Update 1:
{
"from": 0,
"size": 1000,
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "live~",
"fuzziness": "auto"
}
},
{
"query_string": {
"query": "lave~",
"fuzziness": "auto"
}
}
]
}
}
}
You can add the fuzziness parameter to your query, like this:
{
"from": 0,
"size": 1000,
"query": {
"bool": {
"must": {
"query_string": {
"query": "Germany",
"fuzziness": "auto" <--- add this
}
}
}
}
}

How to find the elements greater than integer

I have dictionary below
[{'id': 0, 'Title': 'The Land Girls', 'US Gross': 146083, 'Worldwide Gross': 146083, 'US DVD Sales': 'null', 'Production Budget': 8000000, 'Release Date': 'Jun 12 1998', 'MPAA Rating': 'R', 'Running Time min': 'null', 'Distributor': 'Gramercy', 'Source': 'null', 'Major Genre': 'null', 'Creative Type': 'null', 'Director': 'null', 'Rotten Tomatoes Rating': 'null', 'IMDB Rating': 6.1, 'IMDB Votes': 1071}, {'id': 1, 'Title': 'First Love, Last Rites', 'US Gross': 10876, 'Worldwide Gross': 10876, 'US DVD Sales': 'null', 'Production Budget': 300000, 'Release Date': 'Aug 07 1998', 'MPAA Rating': 'R', 'Running Time min': 'null', 'Distributor': 'Strand', 'Source': 'null', 'Major Genre': 'Drama', 'Creative Type': 'null', 'Director': 'null', 'Rotten Tomatoes Rating': 'null', 'IMDB Rating': 6.9, 'IMDB Votes': 207}, {'id': 2, 'Title': 'I Married a Strange Person', 'US Gross': 203134, 'Worldwide Gross': 203134, 'US DVD Sales': 'null', 'Production Budget': 250000, 'Release Date': 'Aug 28 1998', 'MPAA Rating': 'null', 'Running Time min': 'null', 'Distributor': 'Lionsgate', 'Source': 'null', 'Major Genre': 'Comedy', 'Creative Type': 'null', 'Director': 'null', 'Rotten Tomatoes Rating': 'null', 'IMDB Rating': 6.8, 'IMDB Votes': 865}, {'id': 3, 'Title': "Let's Talk About Sex", 'US Gross': 373615, 'Worldwide Gross': 373615, 'US DVD Sales': 'null', 'Production Budget': 300000, 'Release Date': 'Sep 11 1998', 'MPAA Rating': 'null', 'Running Time min': 'null', 'Distributor': 'Fine Line', 'Source': 'null', 'Major Genre': 'Comedy', 'Creative Type': 'null', 'Director': 'null', 'Rotten Tomatoes Rating': 13, 'IMDB Rating': 'null', 'IMDB Votes': 'null'}, {'id': 4, 'Title': 'Slam', 'US Gross': 1009819, 'Worldwide Gross': 1087521, 'US DVD Sales': 'null', 'Production Budget': 1000000, 'Release Date': 'Oct 09 1998', 'MPAA Rating': 'R', 'Running Time min': 'null', 'Distributor': 'Trimark', 'Source': 'Original Screenplay', 'Major Genre': 'Drama', 'Creative Type': 'Contemporary Fiction', 'Director': 'null', 'Rotten Tomatoes Rating': 62, 'IMDB Rating': 3.4, 'IMDB Votes': 165}, {'id': 5, 'Title': 'Mississippi Mermaid', 'US Gross': 24551, 'Worldwide Gross': 2624551, 'US DVD Sales': 'null', 'Production Budget': 1600000, 'Release Date': 'Jan 15 1999', 'MPAA Rating': 'null', 'Running Time min': 'null', 'Distributor': 'MGM', 'Source': 'null', 'Major Genre': 'null', 'Creative Type': 'null', 'Director': 'null', 'Rotten Tomatoes Rating': 'null', 'IMDB Rating': 'null', 'IMDB Votes': 'null'}, {'id': 6, 'Title': 'Following', 'US Gross': 44705, 'Worldwide Gross': 44705, 'US DVD Sales': 'null', 'Production Budget': 6000, 'Release Date': 'Apr 04 1999', 'MPAA Rating': 'R', 'Running Time min': 'null', 'Distributor': 'Zeitgeist', 'Source': 'null', 'Major Genre': 'null', 'Creative Type': 'null', 'Director': 'Christopher Nolan', 'Rotten Tomatoes Rating': 'null', 'IMDB Rating': 7.7, 'IMDB Votes': 15133}, {'id': 7, 'Title': 'Foolish', 'US Gross': 6026908, 'Worldwide Gross': 6026908, 'US DVD Sales': 'null', 'Production Budget': 1600000, 'Release Date': 'Apr 09 1999', 'MPAA Rating': 'R', 'Running Time min': 'null', 'Distributor': 'Artisan', 'Source': 'Original Screenplay', 'Major Genre': 'Comedy', 'Creative Type': 'Contemporary Fiction', 'Director': 'null', 'Rotten Tomatoes Rating': 'null', 'IMDB Rating': 3.8, 'IMDB Votes': 353}, {'id': 8, 'Title': 'Pirates', 'US Gross': 1641825, 'Worldwide Gross': 6341825, 'US DVD Sales': 'null', 'Production Budget': 40000000, 'Release Date': 'Jul 01 1986', 'MPAA Rating': 'R', 'Running Time min': 'null', 'Distributor': 'null', 'Source': 'null', 'Major Genre': 'null', 'Creative Type': 'null', 'Director': 'Roman Polanski', 'Rotten Tomatoes Rating': 25, 'IMDB Rating': 5.8, 'IMDB Votes': 3275}, {'id': 9, 'Title': 'Duel in the Sun', 'US Gross': 20400000, 'Worldwide Gross': 20400000, 'US DVD Sales': 'null', 'Production Budget': 6000000, 'Release Date': 'Dec 31 2046', 'MPAA Rating': 'null', 'Running Time min': 'null', 'Distributor': 'null', 'Source': 'null', 'Major Genre': 'null', 'Creative Type': 'null', 'Director': 'null', 'Rotten Tomatoes Rating': 86, 'IMDB Rating': 7, 'IMDB Votes': 2906}, {'id': 10, 'Title': 'Tom Jones', 'US Gross': 37600000, 'Worldwide Gross': 37600000, 'US DVD Sales': 'null', 'Production Budget': 1000000, 'Release Date': 'Oct 07 1963', 'MPAA Rating': 'null', 'Running Time min': 'null', 'Distributor': 'null', 'Source': 'null', 'Major Genre': 'null', 'Creative Type': 'null', 'Director': 'null', 'Rotten Tomatoes Rating': 81, 'IMDB Rating': 7, 'IMDB Votes': 4035}, {'id': 11, 'Title': 'Oliver!', 'US Gross': 37402877, 'Worldwide Gross': 37402877, 'US DVD Sales': 'null', 'Production Budget': 10000000, 'Release Date': 'Dec 11 1968', 'MPAA Rating': 'null', 'Running Time min': 'null', 'Distributor': 'Sony Pictures', 'Source': 'null', 'Major Genre': 'Musical', 'Creative Type': 'null', 'Director': 'null', 'Rotten Tomatoes Rating': 84, 'IMDB Rating': 7.5, 'IMDB Votes': 9111}, {'id': 12, 'Title': 'To Kill A Mockingbird', 'US Gross': 13129846, 'Worldwide Gross': 13129846, 'US DVD Sales': 'null', 'Production Budget': 2000000, 'Release Date': 'Dec 25 1962', 'MPAA Rating': 'null', 'Running Time min': 'null', 'Distributor': 'Universal', 'Source': 'null', 'Major Genre': 'null', 'Creative Type': 'null', 'Director': 'null', 'Rotten Tomatoes Rating': 97, 'IMDB Rating': 8.4, 'IMDB Votes': 82786}, {'id': 13, 'Title': 'Tora, Tora, Tora', 'US Gross': 29548291, 'Worldwide Gross': 29548291, 'US DVD Sales': 'null', 'Production Budget': 25000000, 'Release Date': 'Sep 23 1970', 'MPAA Rating': 'null', 'Running Time min': 'null', 'Distributor': 'null', 'Source': 'null', 'Major Genre': 'null', 'Creative Type': 'null', 'Director': 'Richard Fleischer', 'Rotten Tomatoes Rating': 'null', 'IMDB Rating': 'null', 'IMDB Votes': 'null'}, {'id': 14, 'Title': 'Hollywood Shuffle', 'US Gross': 5228617, 'Worldwide Gross': 5228617, 'US DVD Sales': 'null', 'Production Budget': 100000, 'Release Date': 'Mar 01 1987', 'MPAA Rating': 'null', 'Running Time min': 'null', 'Distributor': 'null', 'Source': 'null', 'Major Genre': 'null', 'Creative Type': 'null', 'Director': 'null', 'Rotten Tomatoes Rating': 87, 'IMDB Rating': 6.8, 'IMDB Votes': 1532}]
How to find the movies which IMDB Rating > 6 using DSL query
You can use range query. Try out this below query
{
"query": {
"range": {
"IMDB Rating": {
"gt": 6
}
}
}
}

how to add to different field values and store it in another field in elastic search python (elastic search field operation)

I have written this elastic search query:
es.search(index=['ind1'],doc_type=['doc'])
I am getting following result:
{'_shards': {'failed': 0, 'skipped': 0, 'successful': 5, 'total': 5},
'hits': {'hits': [{'_id': '1327',
'_index': 'ind1',
'_score': 1.0,
'_source': {'val1': 1,
'val2': None,
'value1': 1327,
'value2': 1531,
'new_values': {'nv1': 1,
'nv2': 0},
{'_id': '1349',
'_index': 'ind1',
'_score': 1.0,
'_source': {'val1': 2,
'val2': 3,
'value1': 1328,
'value2': 1539,
'new_values': {'nv1': 1,
'nv2': 3}},.......
I want all the add val1, value1 and nv1 and store it in another field Let's call total. I want the result will be like:
{'_shards': {'failed': 0, 'skipped': 0, 'successful': 5, 'total': 5},
'hits': {'hits': [{'_id': '1327',
'_index': 'ind1',
'_score': 1.0,
'_source': {'val1': 1,
'val2': None,
'value1': 1327,
'value2': 1531,
'new_values': {'nv1': 1,
'nv2': 0},
'total1': 1329},
{'_id': '1349',
'_index': 'ind1',
'_score': 1.0,
'_source': {'val1': 2,
'val2': 3,
'value1': 1328,
'value2': 1539,
'new_values': {'nv1': 1,
'nv2': 3},
'total': 1331},.......
What you can do is use a script field in order to compute that value on the fly:
es.search(index=['ind1'],doc_type=['doc'], body={
'_source': true,
'script_fields': {
'total': {
'script': {
'source': 'doc.val1 + doc.value1 + doc.new_values.nv1'
}
}
}
})
The best way, though, would be to pre-compute that at index time and store the value in a new total field.

Resources