Created
January 8, 2010 08:00
-
-
Save marcosvm/271912 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_id": "e379e2e2b7df884a7657c65f3cb08c61", | |
"_rev": "2-25588bfd1371f41c9f5b67a16b46e7ab", | |
"primary_phone": "Office:966.117.8601 x4688", | |
"type": "account", | |
"account_id": "3", | |
"dislike": 0, | |
"owner_name": "Fred Eqres", | |
"opportunity_id": [ | |
"311", | |
"312" | |
], | |
"prestige": 0, | |
"contact": [ | |
"Anne Schaefer" | |
], | |
"updated_at": "2009/12/17 19:44:43 +0000", | |
"short_summary": "03526 Tamia Cliff Stravenue, West Gaylord, Office:966.117.8601 x4688", | |
"opportunity_name": [ | |
"O'Reilly, Brown and Runolfsson - 49", | |
"O'Reilly, Brown and Runolfsson - 4" | |
], | |
"contact_id": [ | |
"3" | |
], | |
"primary_email": "Office:paige.labadie@aufderhar.co.uk", | |
"first_line": "<b>Account</b>: O'Reilly, Brown and Runolfsson", | |
"company_id": "1", | |
"name": "O'Reilly, Brown and Runolfsson", | |
"search_info": "O'Reilly, Brown and Runolfsson Office:966.117.8601 x4688 9661178601 x4688 Office:paige.labadie@aufderhar.co.uk Office paige.labadie aufderhar.co.uk Office paige labadie aufderhar co uk West Gaylord Fred Eqres", | |
"extended_summary": "<p><b>Open Opportunities</b> O'Reilly, Brown and Runolfsson - 4 2009-12-01 </p> <p><b>Contacts </b> <p>Anne Schaefer Buyer Office:nat_jast@fritsch.com Office:(375)551-5509</p></p>", | |
"id": "3", | |
"like": 0, | |
"index_updated_at": "2009/12/17 19:44:44 +0000", | |
"owner_id": 4, | |
"lead_source": "Ad Campaign" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(doc) { | |
var fields = { | |
"_id" : {"field":"_id","store":"no"}, | |
"name" : {"field":"name","store":"yes", "index":"not_analyzed" }, | |
"id": {"field":"id","store":"yes","type":"integer" }, | |
"type" : {"field":"type", "store":"yes", "index":"not_analyzed" }, | |
"contact" : {"field":"contact", "store":"yes"}, | |
"account" : {"field":"account", "store":"yes"}, | |
"company_id" : {"field":"company_id", "store":"yes"}, | |
"account_id" : {"field":"account_id", "store":"yes"}, | |
"opportunity_id" : {"field":"opportunity_id", "store":"yes"}, | |
"contact_id" : {"field":"contact_id", "store":"yes"}, | |
"initiative_id" : {"field":"initiative_id","store":"yes"}, | |
"interests" : {"field":"interests","store":"yes"}, | |
"user_id" : { "field":"user_id","store":"yes"}, | |
"entity_type" : { "field":"entity_type","store":"yes"}, | |
"entity_subtype" : { "field":"entity_subtype", "store":"yes", "index":"not_analyzed" }, | |
"prestige" : { "field":"prestige","store":"no","type":"integer"}, | |
"like" : { "field":"like","store":"no","type":"integer"}, | |
"updated_at" : { "field":"updated_at","store":"yes","index":"not_analyzed"}, | |
"search_info" : { "field":"search_info","store":"no", "index" : "analyzed"}, | |
"comment_count" : { "field":"comment_count", "store":"no", "type":"integer" }, | |
"primary_phone" : { "field":"primary_phone", "store":"no", "index":"not_analyzed" }, | |
"primary_email" : { "field":"primary_email", "store":"no", "index":"not_analyzed" }, | |
"owner_name" : { "field":"owner_name", "store":"no", "index":"not_analyzed" }, | |
"account_type_name" : { "field":"account_type_name", "store":"no", "index":"not_analyzed" }, | |
"account_name" : { "field":"account_name", "store":"no", "index":"not_analyzed" }, | |
"current_stage_name" : { "field":"current_stage_name", "store":"no", "index":"not_analyzed" }, | |
"close_date" : { "field":"close_date", "store":"no", "index":"not_analyzed" }, | |
"close_amount" : { "field":"close_amount", "store":"no", "type":"double" }, | |
"sale_role_name" : { "field":"sale_role_name", "store":"no", "index":"not_analyzed" }, | |
"item_status_name" : { "field":"item_status_name", "store":"no", "index":"not_analyzed" }, | |
"searchDisplayOrder" : { "field":"search_display_order", "store":"yes", "type":"integer" } | |
}; | |
var searchDisplayOrder = { | |
"account" : 2, | |
"contact" : 1, | |
"goal" : 5, | |
"marketing_analysis" : 6, | |
"opportunity" : 3, | |
"project" : 7, | |
"realtime_analysis" : 8, | |
"strategy" : 9, | |
"user" : 4 | |
}; | |
var ret = new Document(); | |
for (property in doc) { | |
if (doc.hasOwnProperty(property)) { | |
if (fields[property] !== undefined) { | |
ret.add(doc[property], fields[property]) ; | |
} | |
var options = fields[property]; | |
if (options !== undefined) { | |
var value = doc[property]; | |
var tmp = typeof(value) == "string" ? value.toLowerCase() : value; | |
ret.add(tmp, options); | |
} | |
} | |
} | |
if (doc.hasOwnProperty("type")) { | |
var t = doc["type"] !== "initiative" ? doc["type"] : doc["entity_subtype"]; | |
var order; | |
if (t) { | |
order = searchDisplayOrder[t]; | |
} | |
if (!order) { | |
order = 9999; // non-expected types stay at the end | |
} | |
ret.add(order, fields["searchDisplayOrder"]); | |
} | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment