Index: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/solr-ingest/src/main/java/org/hathitrust/extractedfeatures/PerVolumeJSON.java
===================================================================
--- other-projects/hathitrust/wcsa/extracted-features-solr/trunk/solr-ingest/src/main/java/org/hathitrust/extractedfeatures/PerVolumeJSON.java	(revision 31782)
+++ other-projects/hathitrust/wcsa/extracted-features-solr/trunk/solr-ingest/src/main/java/org/hathitrust/extractedfeatures/PerVolumeJSON.java	(revision 31783)
@@ -168,5 +168,7 @@
 							// Convert to Solr add form
 							JSONObject solr_add_doc_json 
-							= SolrDocJSON.generateSolrDocJSON(volume_id, page_id, ef_page, _whitelist_bloomfilter, _universal_langmap, _icu_tokenize);
+							= SolrDocJSON.generateSolrDocJSON(volume_id, page_id, 
+												ef_metadata, ef_page,
+												_whitelist_bloomfilter, _universal_langmap, _icu_tokenize);
 
 
Index: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/solr-ingest/src/main/java/org/hathitrust/extractedfeatures/SolrDocJSON.java
===================================================================
--- other-projects/hathitrust/wcsa/extracted-features-solr/trunk/solr-ingest/src/main/java/org/hathitrust/extractedfeatures/SolrDocJSON.java	(revision 31782)
+++ other-projects/hathitrust/wcsa/extracted-features-solr/trunk/solr-ingest/src/main/java/org/hathitrust/extractedfeatures/SolrDocJSON.java	(revision 31783)
@@ -31,7 +31,43 @@
 public class SolrDocJSON {
 
-	protected static JSONObject generateToplevelMetadataSolrDocJSON(String volume_id, JSONObject ef_metadata)
-	{
-		JSONObject solr_update_json = null;
+	protected static String [] metadata_single = new String[] {
+			"accessProfile",
+			"bibliographicFormat",
+			"dateCreated",              // date
+			//"enumerationChronology",  // What is this?
+			//"governmentDocument",       // bool: true/false
+			"handleUrl",
+			"hathitrustRecordNumber",   // int?
+			"htBibUrl",
+			"imprint",
+			"issuance",
+			"language",
+			"lastUpdateDate",
+			"pubDate",
+			"pubPlace",
+			"rightsAttributes",
+			"schemaVersion",
+			"sourceInstitution",
+			"sourceInstitutionRecordNumber",
+			"title",
+			"typeOfResource",
+			"volumeIdentifier"
+	};
+
+	protected static String [] metadata_multiple = new String[] {
+			"oclc",
+			"isbn",
+			"issn",
+			"lccn",
+			"genre", 	    
+			"names"
+	};
+
+	protected static String [] metadata_hashmap_multiple = new String[] {
+			"classification"
+	};
+	
+	protected static JSONObject generateMetadataSolrDocJSON(String id, JSONObject ef_metadata, boolean is_page_level)
+	{
 		/*
 		 Example JSON for id: "gri.ark:/13960/t0003qw46
@@ -81,41 +117,74 @@
 		 */
 		
-		String [] metadata_single = new String[] {
-				"accessProfile",
-				"bibliographicFormat",
-				"dateCreated",              // date
-				//"enumerationChronology",  // What is this?
-				//"governmentDocument",       // bool: true/false
-				"handleUrl",
-				"hathitrustRecordNumber",   // int?
-				"htBibUrl",
-				"imprint",
-				"issuance",
-				"language",
-				"lastUpdateDate",
-				"pubDate",
-				"pubPlace",
-				"rightsAttributes",
-				"schemaVersion",
-				"sourceInstitution",
-				"sourceInstitutionRecordNumber",
-				"title",
-				"typeOfResource",
-				"volumeIdentifier"
-		};
-
-		String [] metadata_multiple = new String[] {
-				"oclc",
-				"isbn",
-				"issn",
-				"lccn",
-				"genre", 	    
-				"names"
-		};
-
-		String [] metadata_hashmap_multiple = new String[] {
-				"classification"
-		};
-		
+
+		// For JSON Solr format see:
+		//   https://cwiki.apache.org/confluence/display/solr/Uploading+Data+with+Index+Handlers
+
+		//String title= ef_metadata.getString("title");
+
+		JSONObject solr_doc_json = new JSONObject();
+		solr_doc_json.put("id", id);
+
+		for (String metaname: metadata_single) {
+			String metavalue = ef_metadata.getString(metaname);
+			
+			if (metavalue != null) {
+				if (is_page_level) {
+					solr_doc_json.put("volume"+metaname+"_txt",metavalue);
+					solr_doc_json.put("volume"+metaname+"_htrcstring",metavalue);
+				}
+				else {
+					solr_doc_json.put(metaname+"_t",metavalue);
+					solr_doc_json.put(metaname+"_s",metavalue);
+				}
+			}
+		}
+
+		for (String metaname: metadata_multiple) {
+			JSONArray metavalues = ef_metadata.getJSONArray(metaname);
+			if (metavalues != null) {
+				if (is_page_level) {
+					solr_doc_json.put("volume"+metaname+"_txt",metavalues);
+					solr_doc_json.put("volume"+metaname+"_htrcstrings",metavalues);
+				}
+				else {
+					solr_doc_json.put(metaname+"_t",metavalues);
+					solr_doc_json.put(metaname+"_ss",metavalues);
+				}
+			}
+		}
+
+		for (String metaname: metadata_hashmap_multiple) {
+			JSONObject metakeys = ef_metadata.getJSONObject(metaname);
+
+			if (metakeys != null) {
+				
+				Iterator<String> metakey_iter = metakeys.keys();
+				while (metakey_iter.hasNext()) {
+					String metakey = metakey_iter.next();
+
+					JSONArray metavalues = metakeys.getJSONArray(metakey);
+					if (metavalues != null) {
+						String combined_metaname = metaname + "_" + metakey;
+						if (is_page_level) {
+							solr_doc_json.put("volume"+combined_metaname+"_txt",metavalues);
+							solr_doc_json.put("volume"+combined_metaname+"_htrcstrings",metavalues);
+						}
+						else {
+							solr_doc_json.put(combined_metaname+"_t",metavalues);
+							solr_doc_json.put(combined_metaname+"_ss",metavalues);
+						}
+					}	
+				}
+			}
+		}
+
+		return solr_doc_json;
+
+	}
+	
+	protected static JSONObject generateToplevelMetadataSolrDocJSON(String volume_id, JSONObject ef_metadata)
+	{
+		JSONObject solr_update_json = null;
 		
 		if (ef_metadata != null) {
@@ -127,40 +196,5 @@
 			JSONObject solr_add_json = new JSONObject();
 			
-			JSONObject solr_doc_json = new JSONObject();
-			solr_doc_json.put("id", volume_id);
-			
-			for (String metaname: metadata_single) {
-				String metavalue = ef_metadata.getString(metaname);
-				if (metavalue != null) {
-					solr_doc_json.put(metaname+"_t",metavalue);
-					solr_doc_json.put(metaname+"_s",metavalue);
-				}
-			}
-			
-			for (String metaname: metadata_multiple) {
-				JSONArray metavalues = ef_metadata.getJSONArray(metaname);
-				if (metavalues != null) {
-					solr_doc_json.put(metaname+"_t",metavalues);
-					solr_doc_json.put(metaname+"_ss",metavalues);
-				}
-			}
-			
-			for (String metaname: metadata_hashmap_multiple) {
-				JSONObject metakeys = ef_metadata.getJSONObject(metaname);
-				
-				if (metakeys != null) {
-					Iterator<String> metakey_iter = metakeys.keys();
-					while (metakey_iter.hasNext()) {
-						String metakey = metakey_iter.next();
-						
-						JSONArray metavalues = metakeys.getJSONArray(metakey);
-						if (metavalues != null) {
-							String combined_metaname = metaname + "_" + metakey;
-							solr_doc_json.put(combined_metaname+"_t",metavalues);
-							solr_doc_json.put(combined_metaname+"_ss",metavalues);
-						}	
-					}
-				}
-			}
+			JSONObject solr_doc_json = generateMetadataSolrDocJSON(volume_id,ef_metadata,false);
 			
 			solr_add_json.put("commitWithin", 60000); // used to be 5000
@@ -179,4 +213,6 @@
 
 
+	
+	
 	
 	protected static ArrayList<String> getTokenPosCountWords(JSONObject ef_token_pos_count, String page_id,
@@ -599,5 +635,6 @@
 	}
 	
-	protected static JSONObject generateSolrDocJSON(String volume_id, String page_id, JSONObject ef_page,
+	protected static JSONObject generateSolrDocJSON(String volume_id, String page_id, 
+												    JSONObject ef_metadata, JSONObject ef_page,
 											        WhitelistBloomFilter whitelist_bloomfilter, 
 											        UniversalPOSLangMap universal_langmap,
@@ -613,10 +650,13 @@
 	
 					JSONObject solr_add_json = new JSONObject();
-	
+					
 					ArrayList<POSString> text_al = filterSolrTextFields(ef_token_pos_count,page_id,whitelist_bloomfilter,universal_langmap,icu_tokenize);
 					
-					JSONObject solr_doc_json = new JSONObject();
-					solr_doc_json.put("id", page_id);
+					//JSONObject solr_doc_json = new JSONObject();
+					JSONObject solr_doc_json = generateMetadataSolrDocJSON(page_id,ef_metadata,true);
+					
+					//solr_doc_json.put("id", page_id); // now done in generateMetadataSolrDocJSON
 					solr_doc_json.put("volumeid_s", volume_id);
+					
 					if (text_al.size()>0) {
 						addSolrLanguageTextFields(ef_page,text_al, universal_langmap, solr_doc_json);
@@ -626,5 +666,5 @@
 						solr_doc_json.put("efnotext_b", true);
 					}
-					solr_add_json.put("commitWithin", 5000);
+					solr_add_json.put("commitWithin", 60000); // used to be 5000
 					solr_add_json.put("doc", solr_doc_json);
 					
