Se si utilizza SolrSharp, non supporta le query negative.
è necessario modificare QueryParameter.cs (creare un nuovo parametro)
private bool _negativeQuery = false;
public QueryParameter(string field, string value, ParameterJoin parameterJoin = ParameterJoin.AND, bool negativeQuery = false)
{
this._field = field;
this._value = value.Trim();
this._parameterJoin = parameterJoin;
this._negativeQuery = negativeQuery;
}
public bool NegativeQuery
{
get { return _negativeQuery; }
set { _negativeQuery = value; }
}
E in classe QueryParameterCollection.cs, l'override ToString(), guarda se il parametro negativo è vero
arQ[x] = (qp.NegativeQuery ? "-(" : "(") + qp.ToString() + ")" + (qp.Boost != 1 ? "^" + qp.Boost.ToString() : "");
Quando si chiama il creatore del parametro, se si tratta di un valore negativo. Semplice cambio del propertie
List<QueryParameter> QueryParameters = new List<QueryParameter>();
QueryParameters.Add(new QueryParameter("PartnerList", "[* TO *]", ParameterJoin.AND, true));
fonte
2012-09-11 14:38:12
Anche se la pagina SolrQuerySyntax dice -id: [* TO *], solo -id: ["" TO *] ha funzionato per me su solr 1.4. –
Non '? Q = -id: *' funziona pure? – user2043553
@ user2043553 No, se si '? Q = -id: *' si ottiene 'Can not parse '-q: *': '*' o '?' non consentito come primo carattere in WildcardQuery' –