Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 566 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to query SOLR for empty fields?

#1
I have a large solr index, and I have noticed some fields are not updated correctly (the index is dynamic).

This has resulted in some fields having an empty "id" field.

I have tried these queries, but they didn't work:

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

Is there a way to query empty fields?

Thanks
Reply

#2
Try this:

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

#3
According to [SolrQuerySyntax][1], you can use `q=-id:[* TO *]`.


[1]:

[To see links please register here]

Reply

#4
If you are using SolrSharp, it does not support negative queries.

You need to change QueryParameter.cs (Create a new parameter)

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

And in QueryParameterCollection.cs class, the ToString() override, looks if the Negative parameter is true

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

When you call the parameter creator, if it's a negative value. Simple change the propertie

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

Reply

#5
If you have a large index, you should use a default value

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

and then query for this default value.
This is much more efficient than q=-id:["" TO *]
Reply

#6
You can also use it like this.

fq=!id:['' TO *]
Reply

#7
you can do it with filter query
q=\*:\*&fq=-id:*
Reply

#8
One caveat! If you want to compose this via OR or AND you cannot use it in this form:

-myfield:*

but you must use

(*:* NOT myfield:*)

This form is perfectly composable. Apparently SOLR will expand the first form to the second, but only when it is a top node. Hope this saves you some time!
Reply

#9
A note added here, to make the field searchable first, it needs the field type in SOLR schema set to "indexed = true". Then you can use "`field_name:*`" for string type and "`field_name:[* TO *]`" for numeric type.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through