当前位置: 首页>>代码示例>>Python>>正文


Python ElasticSearchController.search_document_for_given_id方法代码示例

本文整理汇总了Python中elastic_controller.ElasticSearchController.search_document_for_given_id方法的典型用法代码示例。如果您正苦于以下问题:Python ElasticSearchController.search_document_for_given_id方法的具体用法?Python ElasticSearchController.search_document_for_given_id怎么用?Python ElasticSearchController.search_document_for_given_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在elastic_controller.ElasticSearchController的用法示例。


在下文中一共展示了ElasticSearchController.search_document_for_given_id方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_location_details_for_map

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def get_location_details_for_map(request_data):
	request_data = json.loads(request_data)
	email = putil.validate_for_user_id_exists(request_data.get("user_id"))
	putil.validate_property_data(request_data, ["request_id"])
	try:
		es = ElasticSearchController()
		response = es.search_document_for_given_id("request",request_data.get("request_id"),[],
														["search_query", "unit_of_area", "adv_search_query"])
		search_query = ast.literal_eval(response.get("adv_search_query").encode("utf8"))
		uom = response.get("unit_of_area")

		include_fields = ["property_title", "property_id", "location", "property_subtype_option",
			                      "operation", "carpet_area", "price", "geo_location_lat", "geo_location_lon" ]

		size = get_count_of_property_records(es)            
		response_data, total_records = es.search_document(["property"], search_query, 1, size, [], include_fields)
		uom = "Sq.Ft." if uom not in ["Sq.Ft.", "Acres", "Hectares"] else uom
		putil.convert_area_according_to_uom(response_data, uom)
		response_msg = "User Property Found" if response_data else "User property not found"
		return {
					"operation":"Search",
					"user_id":request_data.get("user_id"),
					"message":response_msg,
					"data":response_data
				}
	except elasticsearch.TransportError:
		raise DoesNotExistError("Request Id does not exists")
	except elasticsearch.ElasticsearchException,e:
		raise ElasticSearchException(e.error)
开发者ID:pawaranand,项目名称:propshikhari,代码行数:31,代码来源:propshikari_api.py

示例2: get_property_contact

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def get_property_contact(request_data):

	"""
		Get Contact person name, contact_no form property &
		generate lead & enquiry against that user. 

	"""

	if request_data:
		request_data = json.loads(request_data)
		email = putil.validate_for_user_id_exists(request_data.get("user_id"))	
		if not request_data.get("property_id"):
			raise MandatoryError("Mandatory Field Property Id missing")
		try:
			es = ElasticSearchController()
			response = es.search_document_for_given_id("property",request_data.get("property_id"),[],[])
			new_response = { "contact_no": response.get("contact_no"), "contact_person":response.get("contact_person")}
			create_lead_from_userid(request_data, email, response)
			return {	
						"operation":"Search",
						"message":"Contact Details found" if len(new_response) else "Contact Details Not Found", 
						"user_id":request_data.get("user_id"), 
						"data":new_response
					}
		except elasticsearch.TransportError:
			raise DoesNotExistError("Property Id does not exists")
		except Exception,e:
			raise e
开发者ID:pawaranand,项目名称:propshikhari,代码行数:30,代码来源:propshikari_api.py

示例3: get_search_query_of_request_id

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def get_search_query_of_request_id(request_data):
	try:
		es = ElasticSearchController()
		response = es.search_document_for_given_id("request",request_data.get("id"),[],["search_query", "unit_of_area"])
		search_query = ast.literal_eval(response.get("search_query").encode("utf8"))
		return search_query, response.get("unit_of_area")
	except elasticsearch.TransportError:
		raise DoesNotExistError("Request Id does not exists")
	except elasticsearch.ElasticsearchException,e:
		raise ElasticSearchException(e.error)		
开发者ID:pawaranand,项目名称:propshikhari,代码行数:12,代码来源:propshikari_api.py

示例4: get_search_query_of_property_id

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def get_search_query_of_property_id(request_data):
	try:
		es = ElasticSearchController()
		response = es.search_document_for_given_id("property",request_data.get("id"))		
		search_query = putil.generate_search_query_from_property_data(response)
		return search_query, "Sq.Ft."
	except elasticsearch.TransportError:
		raise DoesNotExistError("Property Id does not exists")
	except elasticsearch.ElasticsearchException,e:
		raise ElasticSearchException(e.error)	
开发者ID:pawaranand,项目名称:propshikhari,代码行数:12,代码来源:propshikari_api.py

示例5: get_project_details

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def get_project_details(request_data):
	user_email = putil.validate_for_user_id_exists(request_data.get("user_id"))
	include_list = request_data.get("fields",[])
	try:
		es = ElasticSearchController()
		response = es.search_document_for_given_id("project",request_data.get("project_id"), [], include_list)
		return {"opeartion":"Search", "message":"Project details Found", "data":response}
	except elasticsearch.TransportError:
		raise DoesNotExistError("Project Id does not exists")
	except elasticsearch.ElasticsearchException,e:
		raise ElasticSearchException(e.error)
开发者ID:arpitjain06,项目名称:propshikhari,代码行数:13,代码来源:property_update_api.py

示例6: get_property_of_given_id

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def get_property_of_given_id(request_data):
	if request_data:
		request_data = json.loads(request_data)
		email = putil.validate_for_user_id_exists(request_data.get("user_id"))
		try:
			es = ElasticSearchController()
			response = es.search_document_for_given_id("property",request_data.get("property_id"), ["property_photos"])
			return {"operation":"Search", "message":"Property found" if len(response) else "Property Not Found", "user_id":request_data.get("user_id"), "data":response}
		except elasticsearch.TransportError:
			raise DoesNotExistError("Property Id does not exists")
		except Exception,e:
			raise GetPropertyOperationFailed("Get Property Operation Failed")
开发者ID:Tejal011089,项目名称:propshikhari,代码行数:14,代码来源:propshikari_api.py

示例7: get_property_contact

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def get_property_contact(request_data):
	if request_data:
		request_data = json.loads(request_data)
		email = putil.validate_for_user_id_exists(request_data.get("user_id"))	
		if not request_data.get("property_id"):
			raise MandatoryError("Mandatory Field Property Id missing")
		try:
			es = ElasticSearchController()
			response = es.search_document_for_given_id("property",request_data.get("property_id"),[],["agent_name", "agent_no", "contact_no" ,"contact_person"])
			return {"operation":"Search", "message":"Contact Details found" if len(response) else "Contact Details Not Found", "user_id":request_data.get("user_id"), "data":response}
		except elasticsearch.TransportError:
			raise DoesNotExistError("Property Id does not exists")
		except Exception,e:
			raise OperationFailed("Get Property Contact Operation Failed")
开发者ID:Tejal011089,项目名称:propshikhari,代码行数:16,代码来源:propshikari_api.py

示例8: get_property_images

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def get_property_images(request_data):
	if request_data:
		request_data = json.loads(request_data)
		email = putil.validate_for_user_id_exists(request_data.get("user_id"))
		if not request_data.get("property_id"):
			raise MandatoryError("Property Id not provided")
		try:
			es = ElasticSearchController()
			response = es.search_document_for_given_id("property",request_data.get("property_id"),[],["full_size_images", "thumbnails"])
			return { "operation":"Search", "message":"Property Images Found" if response else "Property Images Not Found", "user_id":request_data.get("user_id"), "data":response }
		except elasticsearch.TransportError:
			raise DoesNotExistError("Property Id does not exists")
		except elasticsearch.ElasticsearchException,e:
			raise ElasticSearchException(e.error)	
		except Exception,e:
			raise OperationFailed("Get Property Images Operation Failed")
开发者ID:pawaranand,项目名称:propshikhari,代码行数:18,代码来源:propshikari_api.py

示例9: get_project_of_given_id

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def get_project_of_given_id(request_data):
	request_data = json.loads(request_data)
	email = putil.validate_for_user_id_exists(request_data.get("user_id"))
	if not request_data.get("project_id"):
		raise MandatoryError("Project id does not exists") 
	try:

		exclude_list = putil.get_exclude_list_for_search("Hunterscamp")
		es = ElasticSearchController()
		response = es.search_document_for_given_id("project", request_data.get("project_id"), exclude_list)
		response_data = putil.get_date_diff_and_count_from_posting([response])
		# putil.show_amenities_with_yes_status(response_data)
		return {"operation":"Search", "message":"Project details found" if len(response) else "Project Not Found", "user_id":request_data.get("user_id"), "data":response_data[0]}
	except elasticsearch.TransportError:
		raise DoesNotExistError("Project Id does not exists")
	except Exception,e:
		raise OperationFailed("Get Project Operation Failed")
开发者ID:arpitjain06,项目名称:propshikhari,代码行数:19,代码来源:project_api.py

示例10: search_group_with_given_criteria

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def search_group_with_given_criteria(request_data):
	if request_data:
		request_data = json.loads(request_data)
		email = putil.validate_for_user_id_exists(request_data.get("user_id"))
		try:
			es = ElasticSearchController()
			response = es.search_document_for_given_id("request",request_data.get("request_id"))
			group_search_conditions = make_conditions_for_group_search(response)
			group_result = frappe.db.sql(""" select  name as group_id, operation, property_type , property_subtype , ifnull(property_subtype_option,"") as property_subtype_option ,ifnull(location,"") as location, ifnull(city,"") as city, ifnull(min_budget,"") as min_budget, ifnull(max_budget,"") as max_budget, ifnull(min_area,"") as min_area, ifnull(max_area,"") as max_area from `tabGroup` {0} """.format(group_search_conditions),as_dict=True)
			for group in group_result:
				join_flag = frappe.db.get_value("Group User" , {"group_id":group.get("group_id"), "user_id":request_data.get("user_id")},"name")
				group["user_joined"] = 1 if join_flag else 0
			return {"operation":"Search", "request_id":request_data.get("request_id"), "data":group_result, "message":"Matching Groups Found" if len(group_result) else "Group Not Found" }
		except elasticsearch.TransportError:
			raise DoesNotExistError("Request Id does not exists")
		except Exception,e:
			return SearchGroupOperationFailed("Search Group Operation Failed")
开发者ID:Tejal011089,项目名称:propshikhari,代码行数:19,代码来源:propshikari_api.py

示例11: get_property_of_given_id

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def get_property_of_given_id(request_data):
	if request_data:
		request_data = json.loads(request_data)
		email = putil.validate_for_user_id_exists(request_data.get("user_id"))
		try:
			exclude_list = ["agent_name", "agent_no", "contact_no", "contact_person", "created_by", 
							"modified_by", "creation_date", "modified_date", "posted_datetime", "modified_datetime", 
							"full_size_images", "thumbnails"]
			es = ElasticSearchController()
			response = es.search_document_for_given_id("property",request_data.get("property_id"), exclude_list)
			return {
						"operation":"Search",
						"message":"Property found" if len(response) else "Property Not Found", 
						"user_id":request_data.get("user_id"), 
						"data":response
					 }
		except elasticsearch.TransportError:
			raise DoesNotExistError("Property Id does not exists")
		except Exception,e:
			raise GetPropertyOperationFailed("Get Property Operation Failed")
开发者ID:pawaranand,项目名称:propshikhari,代码行数:22,代码来源:propshikari_api.py

示例12: get_project_of_given_id

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def get_project_of_given_id(request_data):
	request_data = json.loads(request_data)
	email = putil.validate_for_user_id_exists(request_data.get("user_id"))
	if not request_data.get("project_id"):
		raise MandatoryError("Project id does not exists") 
	try:
		es = ElasticSearchController()
		response = es.search_document_for_given_id("project",request_data.get("project_id"))
		response["properties"]= {}
		for prop in response.get("property_details"):
			if not response["properties"].has_key(prop.get("property_type")):
				response["properties"][prop.get("property_type")] = { "option":{ prop.get("property_subtype_option"):{ "count":prop.get("count"), "area":prop.get("carpet_area")} }}
			else:
				response["properties"][prop.get("property_type")]["option"][prop.get("property_subtype_option")] = 	{ "count":prop.get("count"), "area":prop.get("carpet_area")} 
		response.pop("property_details")
		return {"operation":"Search", "message":"Project found" if len(response) else "Project Not Found", "user_id":request_data.get("user_id"), "data":response}
	except elasticsearch.TransportError:
		raise DoesNotExistError("Project Id does not exists")
	except Exception,e:
		raise OperationFailed("Get Project Operation Failed")
开发者ID:Tejal011089,项目名称:propshikhari,代码行数:22,代码来源:project_api.py

示例13: remove_tag_of_property

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def remove_tag_of_property(data):
	request_data = json.loads(data)
	user_email = putil.validate_for_user_id_exists(request_data.get("user_id"))
	user_data = frappe.db.get_value("User",{"email":user_email}, "user_type", as_dict=True)
	if user_data.get("user_type") == "System User":
		try:
			es = ElasticSearchController()
			response = es.search_document_for_given_id("property",request_data.get("property_id"), [], [])
			get_modified_datetime(response, user_email)
			update_query = get_update_tag_query(request_data,request_data.get('tags')[0],response)
			es = ElasticSearchController()
			update_response = es.update_docuemnt("property", request_data.get("property_id"),update_query)
			es = ElasticSearchController()
			es.refresh_index()
			return {	
						"operation":"update", 
						"user_id":request_data.get("user_id"), 
						"message":"Property Tags Updated Successfully"
					}
		except elasticsearch.TransportError:
			raise DoesNotExistError("Property Id does not exists")
		except elasticsearch.ElasticsearchException,e:
			raise ElasticSearchException(e.error)					
开发者ID:arpitjain06,项目名称:propshikhari,代码行数:25,代码来源:property_update_api.py

示例14: get_property_contact

# 需要导入模块: from elastic_controller import ElasticSearchController [as 别名]
# 或者: from elastic_controller.ElasticSearchController import search_document_for_given_id [as 别名]
def get_property_contact(request_data):

	"""
		Get Contact person name, contact_no form property &
		generate lead & enquiry against that user. 

	"""

	if request_data:
		request_data = json.loads(request_data)
		email = putil.validate_for_user_id_exists(request_data.get("user_id"))	
		if not request_data.get("property_id"):
			raise MandatoryError("Mandatory Field Property Id missing")
		try:
			es = ElasticSearchController()
			response = es.search_document_for_given_id("property",request_data.get("property_id"),[],[])
			mapper = {"Owner":["contact_person", "contact_no"], "Agent":["agent_name", "agent_no"], "Broker":["agent_name", "agent_no"] }
			person_key = response.get("listed_by") if response.get("listed_by") else "Owner" 
			person_no_key = response.get("listed_by") if response.get("listed_by") else "Owner" 
			new_response = { 
								"contact_person": response.get(mapper.get(person_key)[0] ), 
								"contact_no":response.get(mapper.get(person_no_key)[1] ),
								"listed_by":person_key  
							}
			create_lead_from_userid(request_data, email, response)
			return {	
						"operation":"Search",
						"message":"Contact Details found" if len(new_response) else "Contact Details Not Found", 
						"user_id":request_data.get("user_id"), 
						"data":new_response
					}
		except elasticsearch.TransportError:
			raise DoesNotExistError("Property Id does not exists")
		except Exception,e:
			print frappe.get_traceback()
			raise e
开发者ID:arpitjain06,项目名称:propshikhari,代码行数:38,代码来源:propshikari_api.py


注:本文中的elastic_controller.ElasticSearchController.search_document_for_given_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。