pub fn parse(query: String) -> Result<Query, Error> {
    let mut query_inner = Query::default();
    // Don't parse empty string
    if query == "" {
        return Ok(query_inner);
    }
    let mut result = QueryParser::parse(Rule::query, &query)?;
    let tokens = result.next().unwrap();
    parse_query(tokens, &mut query_inner)?;
    if query_inner.is_aggregation_exist() && query_inner.limit != 0 {
        return Err(format_err!(
            "Limit is not supported with aggregation. At least for now"
        ));
    }

    // If there is no limit, update the default limit.
    if query_inner.limit == 0 {
        query_inner.limit = DEFAULT_LIMIT;
    }

    if query_inner.distance == 0 {
        // set the default distance if there is no distance specified.
        query_inner.distance = DEFAULT_DISTANCE;
    }
    Ok(query_inner)
}
/// parse will parse the given query string into internal
/// Pathivu query structure.
parse will parse the given query string into internal
Pathivu query structure.
parse will parse the given query string into internal Pathivu query structure .
pub fn parse(query: String) -> Result<Query, Error> {
    let mut query_inner = Query::default();
    // Don't parse empty string
    if query == "" {
        return Ok(query_inner);
    }
    let mut result = QueryParser::parse(Rule::query, &query)?;
    let tokens = result.next().unwrap();
    parse_query(tokens, &mut query_inner)?;
    if query_inner.is_aggregation_exist() && query_inner.limit != 0 {
        return Err(format_err!(
            "Limit is not supported with aggregation. At least for now"
        ));
    }
    // If there is no limit, update the default limit.
    if query_inner.limit == 0 {
        query_inner.limit = DEFAULT_LIMIT;
    }
    if query_inner.distance == 0 {
        // set the default distance if there is no distance specified.
        query_inner.distance = DEFAULT_DISTANCE;
    }
    Ok(query_inner)
}
pub fn parse ( query : String ) -> Result < Query , Error > { let mut query_inner = Query :: default ( ) ; // Don't parse empty string if query == " " { return Ok ( query_inner ) ; } let mut result = QueryParser :: parse ( Rule :: query , & query ) ? ; let tokens = result . next ( ) . unwrap ( ) ; parse_query ( tokens , & mut query_inner ) ? ; if query_inner . is_aggregation_exist ( ) && query_inner . limit != 0 { return Err ( format_err ! ( " " ) ) ; } // If there is no limit, update the default limit. if query_inner . limit == 0 { query_inner . limit = DEFAULT_LIMIT ; } if query_inner . distance == 0 { // set the default distance if there is no distance specified. query_inner . distance = DEFAULT_DISTANCE ; } Ok ( query_inner ) }
parse will parse the given query string into internal
Pathivu query structure.
parse will parse the given query string into internal Pathivu query structure .
query
String