public int encodeAsProperties(ByteBuffer buffer, boolean encodeQueryData) {
if (! hasEncodableProperties()) return 0;
int start = buffer.position();
int mapCountPosition = buffer.position();
buffer.putInt(0);
int mapCount = 0;
mapCount += ranking.getProperties().encode(buffer, encodeQueryData);
if (encodeQueryData) mapCount += ranking.getFeatures().encode(buffer);
if (encodeQueryData && presentation.getHighlight() != null) mapCount += MapEncoder.encodeStringMultiMap(Highlight.HIGHLIGHTTERMS, presentation.getHighlight().getHighlightTerms(), buffer);
if (encodeQueryData) mapCount += MapEncoder.encodeSingleValue("model", "searchpath", model.getSearchPath(), buffer);
mapCount += MapEncoder.encodeSingleValue(DocumentDatabase.MATCH_PROPERTY, DocumentDatabase.SEARCH_DOC_TYPE_KEY, model.getDocumentDb(), buffer);
mapCount += MapEncoder.encodeMap("caches", createCacheSettingMap(), buffer);
buffer.putInt(mapCountPosition, mapCount);
return buffer.position() - start;
}