IT

빈 필드에 대해 SOLR을 쿼리하는 방법은 무엇입니까?

lottoking 2020. 8. 11. 07:38
반응형

빈 필드에 대해 SOLR을 쿼리하는 방법은 무엇입니까?


큰 solr 기능이 있고 일부 필드가 업데이트되지 않은 것이 많지만 (인덱스는 동적 임)입니다.

이로 인해 일부 필드의 "id"필드가 비어 있습니다.

이 쿼리를 시도했지만 시도하지 않았습니다.

 id:''
 id:NULL
 id:null
 id:""
 id:
 id:['' TO *]

빈 필드를 쿼리하는 방법이 있습니까?

감사합니다


이 시도 :

?q=-id:["" TO *]

한 가지주의 사항! OR을 통해 생성하려는 경우 또는 다음 형식으로 사용할 수 없습니다.

-myfield:*

그러나 당신은 경고합니다

(*:* NOT myfield:*)

이 양식은 완벽하게 구성 할 수 있습니다. 분명히 SOLR은 첫 번째 양식을 두 번째 양식으로 확장하지만 최상위 노드 일 때만 확장됩니다. 이것이 시간을 절약하기를 바랍니다!


에 따르면 SolrQuerySyntax , 당신은 사용할 수 있습니다 q=-id:[* TO *].


큰 색인이있는 경우 경우를 많이 사용합니다.

   <field ... default="EMPTY" />

이 노래를 쿼리합니다. 이것은 q = -id : [ ""TO *]보다 훨씬입니다.


이렇게 사용할 수도 있습니다.

fq=!id:['' TO *]

SolrSharp를 사용하는 경우 사용 가능한 쿼리를 지원하지 않습니다.

QueryParameter.cs를 변경해야합니다 (새 매개 변수 생성).

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; }
}

그리고 QueryParameterCollection.cs 클래스에서 ToString () 재정의는 Negative 매개 변수가 참인지 확인합니다.

arQ[x] = (qp.NegativeQuery ? "-(" : "(") + qp.ToString() + ")" + (qp.Boost != 1 ? "^" + qp.Boost.ToString() : "");

매개 변수 작성자를 호출 할 때 음수 값이면. 간단한 속성 변경

List<QueryParameter> QueryParameters = new List<QueryParameter>();
QueryParameters.Add(new QueryParameter("PartnerList", "[* TO *]", ParameterJoin.AND, true));

필터 쿼리 q = * : * & fq = -id : *로 수행 할 수 있습니다.

참고 URL : https://stackoverflow.com/questions/4238609/how-to-query-solr-for-empty-fields

반응형