Jeśli używasz SolrSharp, nie obsługuje negatywnych zapytań.
Musisz zmienić QueryParameter.cs (Utwórz nowy parametr)
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; }
}
A w klasie QueryParameterCollection.cs, ToString() przesłanianie, wygląda jeśli parametr Negative prawda
arQ[x] = (qp.NegativeQuery ? "-(" : "(") + qp.ToString() + ")" + (qp.Boost != 1 ? "^" + qp.Boost.ToString() : "");
Po wywołaniu kreatora parametrów, jeśli jest to wartość ujemna. Proste Zmiana propertie
List<QueryParameter> QueryParameters = new List<QueryParameter>();
QueryParameters.Add(new QueryParameter("PartnerList", "[* TO *]", ParameterJoin.AND, true));
Mimo że strona SolrQuerySyntax mówi -id: [* TO *], tylko -id: ["TO *] działało dla mnie na Solr 1.4. –
Czy '? Q = -id: *' również nie działa? – user2043553
@ user2043553 Nie, jeśli '' q = -id: * 'otrzymasz' Can not parsse '-q: *': '*' lub '?' niedozwolone jako pierwszy znak w WildcardQuery' –