@@ -40,8 +40,8 @@ def __str__(self):
4040class IndexDefinition (object ):
4141 def __init__ (self , index_map , name = None , ** kwargs ):
4242 """
43- @param index_maps : The map of the index
44- :type str
43+ @param index_map : The map of the index
44+ :type str or tuple
4545 @param name: The name of the index
4646 :type str
4747 @param kwargs: Can be use to initialize the other option in the index definition
@@ -58,16 +58,14 @@ def __init__(self, index_map, name=None, **kwargs):
5858 self ._is_compiled = False
5959 self .is_side_by_side_index = kwargs .get ("is_side_by_side_index" , False )
6060 self .is_test_index = kwargs .get ("is_test_index" , False )
61- self .is_map_reduce = kwargs .get ("is_map_reduce" , False )
6261 self .lock_mod = kwargs .get ("lock_mod" , IndexLockMode .Unlock )
6362 self .max_index_outputs_per_document = kwargs .get ("max_index_outputs_per_document" , None )
6463 self .sort_options = kwargs .get ("sort_options" , {})
6564 self .spatial_indexes = kwargs .get ("spatial_indexes" , {})
6665 self .stores = kwargs .get ("stores" , {})
6766 self .suggestions = kwargs .get ("suggestions" , {})
6867 self .term_vectors = kwargs .get ("term_vectors" , {})
69- self .maps = kwargs .get ("maps" , set ())
70- self .map = index_map
68+ self .maps = (index_map ,) if isinstance (index_map , str ) else tuple (set (index_map , ))
7169
7270 @property
7371 def type (self ):
@@ -79,9 +77,15 @@ def type(self):
7977 return "MapReduce"
8078 return "Map"
8179
80+ @property
81+ def is_map_reduce (self ):
82+ return True if self .reduce else False
83+
8284 @property
8385 def map (self ):
84- return list (self .maps )[0 ]
86+ if not isinstance (self .maps , str ):
87+ return self .maps [0 ]
88+ return self .maps
8589
8690 @map .setter
8791 def map (self , value ):
@@ -96,7 +100,7 @@ def to_json(self):
96100 "InternalFieldsMapping" : self .internal_fields_mapping , "IsCompiled" : self ._is_compiled ,
97101 "IsMapReduce" : self .is_map_reduce , "IsSideBySideIndex" : self .is_side_by_side_index ,
98102 "IsTestIndex" : self .is_test_index , "LockMode" : str (self .lock_mod ), "Map" : self .map ,
99- "Maps" : list ( self .maps ) ,
103+ "Maps" : self .maps ,
100104 "MaxIndexOutputsPerDocument" : self .max_index_outputs_per_document , "Name" : self .name ,
101105 "Reduce" : self .reduce , "SortOptions" : {key : str (self .sort_options [key ]) for key in self .sort_options },
102106 "SpatialIndexes" : self .spatial_indexes ,
@@ -115,6 +119,8 @@ def __init__(self, query="", total_size=0, skipped_results=0, default_operator=N
115119 :type int
116120 @param default_operator: The operator of the query (AND or OR) the default value is OR
117121 :type Enum.QueryOperator
122+ @param fetch fetch only the terms you want from the index
123+ :type list
118124 """
119125 self .query = query
120126 self .total_size = total_size
@@ -124,6 +130,7 @@ def __init__(self, query="", total_size=0, skipped_results=0, default_operator=N
124130 self .default_operator = default_operator
125131 self .sort_hints = kwargs .get ("sort_hints" , {})
126132 self .sort_fields = kwargs .get ("sort_fields" , {})
133+ self .fetch = kwargs .get ("fetch" , [])
127134 self .wait_for_non_stale_results = kwargs .get ("wait_for_non_stale_results" , False )
128135
129136 @property
0 commit comments