How can I change this query to find only records with numeric value of telephoneNumber attribute?
(&(objectClass=user)(telephoneNumber=*)(MemberOf=CN=Users,OU=Groups,DC=domain,DC=local))"
I have to be sure that this field contains only digits.
You can't do that with an LDAP filter.
You may however be able to constrain the attribute, so that non-numerical never get in there in the first place.
Related
Below query gives be the unique values of that field. But it returns only top 100. Not sure how to get all the unique values.
"'http://localhost:8983/solr/select/?q=%3A&rows=0&facet=on&facet.field=txt'"
PS: My field is a tokenized field. Not sure if that makes any difference.
You can use facet.limit to change the number of returned values. Set it to -1 to make Solr return all possible values for a field and not just the top 100.
&facet=on&facet.field=txt&facet.limit=-1
You can also use f.txt.facet.limit=-1 if you have more than one facet and just want to change the value for that single field.
You can also use the Terms component to retrieve the tokens indexed for a specific field - depending on your use case it might be more efficient to use the terms component instead - you'll have to evaluate the performance for your exact use case and setup.
I need to filter for documents that have a specific value for a field and all documents which do not have the field :
fq":"((state:"CA") OR NOT(state:*))"
when I execute each subcomponent separately it gives results however when I execute them together I am getting 0 documents found.
You have to subtract the NOT from something.
fq=state:CA OR (*:* NOT state:[* TO *])
So either it's in the set denoted by state:CA, or it's in the set denoted by all documents, minus those that have a value in the field. You can't just say "minus those that have a value in the field", since there is nothing to subtract from (small nitpick: Solr automagically adds the whole set to purely negative queries, so q=-state:[* TO *] would work - but not when you add the boolean operators).
I have a field named "disabled" which is multivalued. I will be running a filter query on this field which will basically search for a specific value on this field i.e. fq=disabled:I
I can map the value "I" to an integer and store the corresponding integers into solr and do filter query based on integers.
So I wanted to know if it is better to store the field as solr.trieInt or solr.strField type is better from a performance point of view?
You will not notice any difference. If you were going to run range queries, then it might be more efficient to store it in a Int field, but for a simple lookup, it will not make a difference.
Note too, that 'trie' versions of numeric are not the latest ones, there are Point based numeric types that seem to be even better.
I have two fields
text field .. All important fields like category, product name, brand are copied into it.
attributes field .. All attributes are copied into this field.
I have a single search query e.g. "50 mm diameter drill"
I want to search this string in both fields. I am assuming that this will match all products that have drill in the text field.
I want to narrow down the result in case any attributes that match any of 50 mm diameter.
And in case none matches in the attributes field I want to return all documents that match text field.
Edit: I dont want any docs which don't match text field.
I only want that if search is matched to attributes field, and docs are found we return only those docs.
If not found we return all docs which match text field
This is getting a bit tricky and a lot of things depend on your field processing requirements.
You will need to use a combination of field weighting, to rank attributes field higher and edismax minimum match mm
Minimum match allows you to configure how many terms in the query must be hit in order for it to display results. This helps weed out documents that only hit on one term in one field.
Lastly, if you really want to have your own logic in here, you can prepend field with + to make it mandatory. For example +attributes:drill will only return items that have drill in the attributes field.
Whether "drill" will match depends on how your fields are processed, but probably, yes. The easiest way to do this is to not limit by "if not matched here, do this ..", but to score matches in the attributes field higher. You can do this by using qf (if using (e)dismax) together with their weights, such as attributes^20 text which will score any match in attributes 20 times more than a match in text. Any search matching documents with the correct term in attributes will then be scored higher than those just matching in text.
You can also do something similar in the q parameter, where you can weight each term separately: text:drill OR attributes:drill^20.
I've a string field defined in SOLR that is populated with values such as "020001" and "50002" etc...
I require it to be a string field since I tokenize it for filtering purposes. Now, when I try to sort on this field it shows wrong order (not even ASCII). Is there a way to sort this field in the asc./desc. order? Thanks.
If you sort on a tokenized field, you're probably sorting on a multivalued field, which is something which will probably not give you the result you're expecting.
You can solve this by adding a dedicated field for sorting that contain the value you want to sort by, which will also allow you to use a more proper field type (such as tint) if you want to parse the value into an integer or still use it as a String value.