Aggiungi tag indice BLOB
Con l’aumento delle dimensioni dei set di dati, può essere difficile trovare un oggetto specifico in un mare di dati. I tag di indice BLOB forniscono funzionalità di gestione e individuazione dei dati utilizzando gli attributi dei tag di indice chiave-valore. È possibile categorizzare e trovare oggetti all'interno di un singolo contenitore o in tutti i contenitori nell'account di archiviazione. Ad esempio, tag indice BLOB CustomerType=Platinum , dove Platinum è il valore del campo CustomerType.
Il codice seguente crea la stringa dei tag dei dati dell'indice BLOB con i valori corrispondenti dai dati inviati
@Override
public String getMetaDataTags(String submittedFormName,String formPath,Session session,String formData) {
JsonObject jsonObject = JsonParser.parseString(formData).getAsJsonObject();
List<String>metaDataTags = new ArrayList<String>();
metaDataTags.add("formName="+submittedFormName);
Map< String, String > map = new HashMap< String, String >();
map.put("path", formPath);
map.put("1_property", "Searchable");
map.put("1_property.value","true");
Query query = queryBuilder.createQuery(PredicateGroup.create(map),session);
query.setStart(0);
query.setHitsPerPage(20);
SearchResult result = query.getResult();
logger.debug("Get result hits " + result.getHits().size());
for (Hit hit: result.getHits()) {
try {
logger.debug(hit.getPath());
String jsonElementName = (String) hit.getProperties().get("name");
String fieldName = hit.getProperties().get("name").toString();
if(jsonObject.get(jsonElementName).isJsonArray())
{
JsonArray arrayOfValues = jsonObject.get(jsonElementName).getAsJsonArray();
StringBuilder valuesString = new StringBuilder();
for(int j=0;j<arrayOfValues.size();j++)
{
valuesString.append(arrayOfValues.get(j).getAsString());
if(j < arrayOfValues.size() -1)
{
valuesString.append(" and ");
}
}
metaDataTags.add(fieldName + "=" + valuesString.toString());
}
else
{
logger.debug("The searchable field name is " + fieldName + "the json element name is " + jsonElementName);
metaDataTags.add(fieldName + "=" + jsonObject.get(jsonElementName).getAsString());
}
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
}
return String.join("&",metaDataTags);
}
4859a77c-7971-4ac9-8f5c-4260823c6f69