You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Modassar Ather <mo...@gmail.com> on 2018/11/05 10:20:26 UTC

Restrict search on term/phrase count in document.

Hi,

Is there a way to restrict search with a term/phrase occurring n number of
times in it?
For example, find the documents which has a term/phrase 5 or more times in
them.

The "Terms component" seems to provide a way but not sure how it will work
for complex queries.
Please note that the Solr version I am using is 6.5.1. Kindly provide your
inputs.

Best,
Modassar

Re: Restrict search on term/phrase count in document.

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
That is kind of unusual. What is the business issue you are trying to
solve? Perhaps there is a different way to look at this problem.

Regards,
     Alex

On Mon, Nov 5, 2018, 5:20 AM Modassar Ather <modather1981@gmail.com wrote:

> Hi,
>
> Is there a way to restrict search with a term/phrase occurring n number of
> times in it?
> For example, find the documents which has a term/phrase 5 or more times in
> them.
>
> The "Terms component" seems to provide a way but not sure how it will work
> for complex queries.
> Please note that the Solr version I am using is 6.5.1. Kindly provide your
> inputs.
>
> Best,
> Modassar
>

Re: Restrict search on term/phrase count in document.

Posted by Modassar Ather <mo...@gmail.com>.
Thanks for your replies.

The requirement is basically to avoid documents which may have a match but
with very less number of term or phrase in it. May a be 1/2 matches.
The user is interested in those document which has matched term/phrase
beyond a certain number.
This can be a valid feature/requirement.

Best,
Modassar

On Mon, Nov 19, 2018 at 10:55 PM Alessandro Benedetti <a....@sease.io>
wrote:

> I agree with Alexandre, it seems suspicious.
> Anyway, if you want to query for single term frequencies occurrence you
> could make use of the function range query parser :
>
>
> https://lucene.apache.org/solr/guide/6_6/other-parsers.html#OtherParsers-FunctionRangeQueryParser
>
> And the function:
>
> termfreq
> Returns the number of times the term appears in the field for that
> document.
> termfreq(text,'memory')
>
> tf
> Term frequency; returns the term frequency factor for the given term, using
> the Similarity for the field. The tf-idf value increases proportionally to
> the number of times a word appears in the document, but is offset by the
> frequency of the word in the document, which helps to control for the fact
> that some words are generally more common than others. See also idf.
> tf(text,'solr')
>
> Cheers
>
>
>
> -----
> ---------------
> Alessandro Benedetti
> Search Consultant, R&D Software Engineer, Director
> Sease Ltd. - www.sease.io
> --
> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
>

Re: Restrict search on term/phrase count in document.

Posted by Alessandro Benedetti <a....@sease.io>.
I agree with Alexandre, it seems suspicious.
Anyway, if you want to query for single term frequencies occurrence you
could make use of the function range query parser :

https://lucene.apache.org/solr/guide/6_6/other-parsers.html#OtherParsers-FunctionRangeQueryParser

And the function:

termfreq
Returns the number of times the term appears in the field for that document.
termfreq(text,'memory')

tf
Term frequency; returns the term frequency factor for the given term, using
the Similarity for the field. The tf-idf value increases proportionally to
the number of times a word appears in the document, but is offset by the
frequency of the word in the document, which helps to control for the fact
that some words are generally more common than others. See also idf.
tf(text,'solr')

Cheers



-----
---------------
Alessandro Benedetti
Search Consultant, R&D Software Engineer, Director
Sease Ltd. - www.sease.io
--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html