com.adobe.cq.social.srp.internal.LuceneToSolr Maven / Gradle / Ivy
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2012 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
package com.adobe.cq.social.srp.internal;
import com.adobe.cq.social.srp.internal.AbstractSchemaMapper;
/**
* Used to map lucene query to Solr query. Right now a simple implementation via the SolrDataMapper.
*/
public class LuceneToSolr {
private final String luceneQuery;
private final AbstractSchemaMapper mapper;
/**
* Constructor.
* @param mapper AbstractSchemaMapper
* @param luceneQuery the lucene query
*/
public LuceneToSolr(final AbstractSchemaMapper mapper, final String luceneQuery) {
this.luceneQuery = luceneQuery;
this.mapper = mapper;
}
/**
* Get the Solr query. Note: for now this uses the simplistic mapping in SolrDataMapper since we're only handling
* a simplified set of queries. Once we add date ranges ets, we may need to use the QueryParser, but the parser if
* very unforgiving of any syntax "errors"
* @return the Solr query
*/
public String getSolrQuery() {
final String solrQuery = mapper.luceneToSolr(luceneQuery);
return solrQuery;
}
}