public String parse ( String query ) throws Exception { if ( StringUtils . isEmpty ( query ) ) { return "" ; } Map < String , Object > jsonFacetMap = new LinkedHashMap <> ( ) ; String [ ] split = query . split ( FACET_SEPARATOR ) ; for ( String facet : split ) { if ( facet . contains ( NESTED_FACET_SEPARATOR ) ) { parseNestedFacet ( facet , jsonFacetMap ) ; } else { List < String > simpleFacets = getSubFacets ( facet ) ; for ( String simpleFacet : simpleFacets ) { parseSimpleFacet ( simpleFacet , jsonFacetMap ) ; } } } return parseJson ( new ObjectMapper ( ) . writeValueAsString ( jsonFacetMap ) ) ; }
This method accepts a simple facet declaration format and converts it into a rich JSON query .