Ring geospatial query

2017-12-04 Thread sp
Hello,

Does lucene java api have a way to do a ring geospatial query around a
LatLonPoint and return the results sorted by distance? By ring, I mean
points which lie beyond an inner radius and within an outer radius

Any suggestions are greatly appreciated.
Thanks



--
Sent from: http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html

-
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org



Re: Ring geospatial query

2017-12-04 Thread Adrien Grand
We don't have such a query, but there are workarounds.
 - If you need this feature for pagination, you should instead use
IndexSearcher.searchAfter with a LatLonPointSortField.
 - If your documents have a single geo-point, you could build a boolean
query with a distance query or the outer radius a a FILTER clause and a
distance query of the inner radius as a MUST_NOT clause.

Le lun. 4 déc. 2017 à 09:16, sp  a écrit :

> Hello,
>
> Does lucene java api have a way to do a ring geospatial query around a
> LatLonPoint and return the results sorted by distance? By ring, I mean
> points which lie beyond an inner radius and within an outer radius
>
> Any suggestions are greatly appreciated.
> Thanks
>
>
>
> --
> Sent from:
> http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
>
> -
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>


Re: Scorer.iterator() - how to implement correctly

2017-12-04 Thread Vadim Gindin
Adrien.

I've found some working solution. Here is how it calculates iterator:

this.iterator = context.reader().postings(query.getTerm(), PostingsEnum.ALL);
if (this.iterator == null) this.iterator = DocIdSetIterator.empty();


Is that implementation correct?

On Sun, Dec 3, 2017 at 4:43 PM, Vadim Gindin  wrote:

> Hi Adrien.
>
> ConstantScoreQuery - I'd tried that earlier. There is the problem. It
> returns score = 0.0 for my configuration with Boolean.. I've debugged and
> found, that it happens because of the following:
>
> @Override
> public Weight createWeight(IndexSearcher searcher, boolean needsScores, float 
> boost) throws IOException {
>   final Weight innerWeight = searcher.createWeight(query, false, 1f);
>   if (needsScores) {
> return new ConstantScoreWeight(this, boost) {
>
>
> As you can see innerWeight is created with needsScores=false  and further
> innerWeight.scorerSuplier will return null. That will lead to 0.0 final
> score.
>
> Moreover I'm trying to start my current logic from simple step. That's why
> I wanted to implement something simple and decide to write it from scratch.
>
> Ok, as you say - iterator is the reason of returning all documents. *So
> how to properly implement scorer.iterator()?*
>
> Many thanks for your help!
> Regards
> Vadim Gindin
>
> On Fri, Dec 1, 2017 at 1:11 PM, Adrien Grand  wrote:
>
>> There are many implementations because each query typically needs a custom
>> DocIdSetIterator implementation. It looks like your use-case doesn't need
>> a
>> custom query though, you could use a TermQuery wrapped in a constant-score
>> query (see my reply to the other question you asked).
>>
>> Le ven. 1 déc. 2017 à 08:24, Vadim Gindin  a écrit
>> :
>>
>> > Hi
>> >
>> > I'm implementing the custom QUERY with appropriate custom WEIGHT and
>> > SCORER.
>> >
>> > I'm trying to implement Scorer.iterator() method. It should return an
>> > iterator of documents that matches the query. Right? There are a lot of
>> > descendant classes of the DocIdSetIterato.
>> >
>> > 1. How to choose correct one?
>> > 2. How to correctly implement Scorer.iterator() method?
>> >
>> > I've tried DocIdSetIterator.all(context.reader().maxDoc());
>> >
>> > But as I can see it returns all documents.
>> >
>> > My task looks simple. I need to return a constant score depending on the
>> > matched fields. I.e. field "model" score - 3f, field "vendor" - score -
>> 5f.
>> >
>> > I'm creating a subquery for each field and specify score for it using
>> > custom QUERY that is almost the same as TermQuery except Weight.Scorer
>> >
>> > Any help is appreciated.
>> >
>> > Regards,
>> > Vadim Gindin
>> >
>>
>
>


Tracking that all query terms are matched in one document

2017-12-04 Thread Vadim Gindin
Hi all.

I need to track that all query terms are matched in one document. When all
terms are matched I need to multiply the score of such document to some
constant coefficient.


Re: Tracking that all query terms are matched in one document

2017-12-04 Thread Vadim Gindin
Sorry

I've accidentally sent an unfinished letter ).

Could somebody advise me the way how to implement the following thing?

Regards
Vadim Gindin

On Mon, Dec 4, 2017 at 3:12 PM, Vadim Gindin  wrote:

> Hi all.
>
> I need to track that all query terms are matched in one document. When all
> terms are matched I need to multiply the score of such document to some
> constant coefficient.
>
>


Re: Scorer.iterator() - how to implement correctly

2017-12-04 Thread Adrien Grand
It is correct... but ConstantScoreQuery is the way to go with your
use-case. It should not return scores of 0 unless you are misusing the API
in some way. Please share the code that you use in order to build your
query.

Le lun. 4 déc. 2017 à 11:10, Vadim Gindin  a écrit :

> Adrien.
>
> I've found some working solution. Here is how it calculates iterator:
>
> this.iterator = context.reader().postings(query.getTerm(),
> PostingsEnum.ALL);
> if (this.iterator == null) this.iterator = DocIdSetIterator.empty();
>
>
> Is that implementation correct?
>
> On Sun, Dec 3, 2017 at 4:43 PM, Vadim Gindin  wrote:
>
> > Hi Adrien.
> >
> > ConstantScoreQuery - I'd tried that earlier. There is the problem. It
> > returns score = 0.0 for my configuration with Boolean.. I've debugged and
> > found, that it happens because of the following:
> >
> > @Override
> > public Weight createWeight(IndexSearcher searcher, boolean needsScores,
> float boost) throws IOException {
> >   final Weight innerWeight = searcher.createWeight(query, false, 1f);
> >   if (needsScores) {
> > return new ConstantScoreWeight(this, boost) {
> >
> >
> > As you can see innerWeight is created with needsScores=false  and further
> > innerWeight.scorerSuplier will return null. That will lead to 0.0 final
> > score.
> >
> > Moreover I'm trying to start my current logic from simple step. That's
> why
> > I wanted to implement something simple and decide to write it from
> scratch.
> >
> > Ok, as you say - iterator is the reason of returning all documents. *So
> > how to properly implement scorer.iterator()?*
> >
> > Many thanks for your help!
> > Regards
> > Vadim Gindin
> >
> > On Fri, Dec 1, 2017 at 1:11 PM, Adrien Grand  wrote:
> >
> >> There are many implementations because each query typically needs a
> custom
> >> DocIdSetIterator implementation. It looks like your use-case doesn't
> need
> >> a
> >> custom query though, you could use a TermQuery wrapped in a
> constant-score
> >> query (see my reply to the other question you asked).
> >>
> >> Le ven. 1 déc. 2017 à 08:24, Vadim Gindin  a
> écrit
> >> :
> >>
> >> > Hi
> >> >
> >> > I'm implementing the custom QUERY with appropriate custom WEIGHT and
> >> > SCORER.
> >> >
> >> > I'm trying to implement Scorer.iterator() method. It should return an
> >> > iterator of documents that matches the query. Right? There are a lot
> of
> >> > descendant classes of the DocIdSetIterato.
> >> >
> >> > 1. How to choose correct one?
> >> > 2. How to correctly implement Scorer.iterator() method?
> >> >
> >> > I've tried DocIdSetIterator.all(context.reader().maxDoc());
> >> >
> >> > But as I can see it returns all documents.
> >> >
> >> > My task looks simple. I need to return a constant score depending on
> the
> >> > matched fields. I.e. field "model" score - 3f, field "vendor" - score
> -
> >> 5f.
> >> >
> >> > I'm creating a subquery for each field and specify score for it using
> >> > custom QUERY that is almost the same as TermQuery except Weight.Scorer
> >> >
> >> > Any help is appreciated.
> >> >
> >> > Regards,
> >> > Vadim Gindin
> >> >
> >>
> >
> >
>


Re: Tracking that all query terms are matched in one document

2017-12-04 Thread Michael Sokolov
You could combine a Boolean and query with the same terms, as an optional
clause. Are you sure about the requirement to multiply the score in that
case?

On Dec 4, 2017 5:13 AM, "Vadim Gindin"  wrote:

> Hi all.
>
> I need to track that all query terms are matched in one document. When all
> terms are matched I need to multiply the score of such document to some
> constant coefficient.
>


Re: Tracking that all query terms are matched in one document

2017-12-04 Thread Vadim Gindin
Thanks, Michael!

Yes, I'm sure. Could you explain your proposal in more detail?

Regards,
Vadim Gindin

On Mon, Dec 4, 2017 at 3:18 PM, Michael Sokolov  wrote:

> You could combine a Boolean and query with the same terms, as an optional
> clause. Are you sure about the requirement to multiply the score in that
> case?
>
> On Dec 4, 2017 5:13 AM, "Vadim Gindin"  wrote:
>
> > Hi all.
> >
> > I need to track that all query terms are matched in one document. When
> all
> > terms are matched I need to multiply the score of such document to some
> > constant coefficient.
> >
>


Re: Scorer.iterator() - how to implement correctly

2017-12-04 Thread Vadim Gindin
Adrien, you're right. I've checked it again - it starts working. Probably,
I had an error in my index causing wrong behavior or yes misusing API. Here
is my code

BooleanQuery.Builder expected = new BooleanQuery.Builder();

Query param_vendor = new BoostQuery(new ConstantScoreQuery(new
TermQuery(new Term("param_vendor", queryStr))), 5f);
Query param_model = new BoostQuery(new ConstantScoreQuery(new
TermQuery(new Term("param_model", queryStr))), 5f);
Query param_value = new BoostQuery(new ConstantScoreQuery(new
TermQuery(new Term("param_value", queryStr))), 3f);
Query param_name = new BoostQuery(new ConstantScoreQuery(new
TermQuery(new Term("param_name", queryStr))), 4f);

BooleanQuery bq = expected
.add(param_vendor, BooleanClause.Occur.SHOULD)
.add(param_model, BooleanClause.Occur.SHOULD)
.add(param_value, BooleanClause.Occur.SHOULD)
.add(param_name, BooleanClause.Occur.SHOULD)
.setMinimumNumberShouldMatch(1)
.build();

return new BoostQuery(bq, queryBoost);

ConstantScoreQuery returns always 1 which is multiplied each time by a
corresponding "field' boost and finally multiplied to query boost. Now it
works.

Thank's a lot!

Regards,
Vadim Gindin

On Mon, Dec 4, 2017 at 3:17 PM, Adrien Grand  wrote:

> It is correct... but ConstantScoreQuery is the way to go with your
> use-case. It should not return scores of 0 unless you are misusing the API
> in some way. Please share the code that you use in order to build your
> query.
>
> Le lun. 4 déc. 2017 à 11:10, Vadim Gindin  a écrit :
>
> > Adrien.
> >
> > I've found some working solution. Here is how it calculates iterator:
> >
> > this.iterator = context.reader().postings(query.getTerm(),
> > PostingsEnum.ALL);
> > if (this.iterator == null) this.iterator = DocIdSetIterator.empty();
> >
> >
> > Is that implementation correct?
> >
> > On Sun, Dec 3, 2017 at 4:43 PM, Vadim Gindin 
> wrote:
> >
> > > Hi Adrien.
> > >
> > > ConstantScoreQuery - I'd tried that earlier. There is the problem. It
> > > returns score = 0.0 for my configuration with Boolean.. I've debugged
> and
> > > found, that it happens because of the following:
> > >
> > > @Override
> > > public Weight createWeight(IndexSearcher searcher, boolean needsScores,
> > float boost) throws IOException {
> > >   final Weight innerWeight = searcher.createWeight(query, false, 1f);
> > >   if (needsScores) {
> > > return new ConstantScoreWeight(this, boost) {
> > >
> > >
> > > As you can see innerWeight is created with needsScores=false  and
> further
> > > innerWeight.scorerSuplier will return null. That will lead to 0.0 final
> > > score.
> > >
> > > Moreover I'm trying to start my current logic from simple step. That's
> > why
> > > I wanted to implement something simple and decide to write it from
> > scratch.
> > >
> > > Ok, as you say - iterator is the reason of returning all documents. *So
> > > how to properly implement scorer.iterator()?*
> > >
> > > Many thanks for your help!
> > > Regards
> > > Vadim Gindin
> > >
> > > On Fri, Dec 1, 2017 at 1:11 PM, Adrien Grand 
> wrote:
> > >
> > >> There are many implementations because each query typically needs a
> > custom
> > >> DocIdSetIterator implementation. It looks like your use-case doesn't
> > need
> > >> a
> > >> custom query though, you could use a TermQuery wrapped in a
> > constant-score
> > >> query (see my reply to the other question you asked).
> > >>
> > >> Le ven. 1 déc. 2017 à 08:24, Vadim Gindin  a
> > écrit
> > >> :
> > >>
> > >> > Hi
> > >> >
> > >> > I'm implementing the custom QUERY with appropriate custom WEIGHT and
> > >> > SCORER.
> > >> >
> > >> > I'm trying to implement Scorer.iterator() method. It should return
> an
> > >> > iterator of documents that matches the query. Right? There are a lot
> > of
> > >> > descendant classes of the DocIdSetIterato.
> > >> >
> > >> > 1. How to choose correct one?
> > >> > 2. How to correctly implement Scorer.iterator() method?
> > >> >
> > >> > I've tried DocIdSetIterator.all(context.reader().maxDoc());
> > >> >
> > >> > But as I can see it returns all documents.
> > >> >
> > >> > My task looks simple. I need to return a constant score depending on
> > the
> > >> > matched fields. I.e. field "model" score - 3f, field "vendor" -
> score
> > -
> > >> 5f.
> > >> >
> > >> > I'm creating a subquery for each field and specify score for it
> using
> > >> > custom QUERY that is almost the same as TermQuery except
> Weight.Scorer
> > >> >
> > >> > Any help is appreciated.
> > >> >
> > >> > Regards,
> > >> > Vadim Gindin
> > >> >
> > >>
> > >
> > >
> >
>


Re: how to compile lucene 4.10.4 using jdk7

2017-12-04 Thread Adrien Grand
I suspect you are not using the version you think you are using at compile
time, this error message suggests that you are actually compiling with Java
9. See this email thread which has a bit more information about this issue:
http://mail-archives.apache.org/mod_mbox/lucene-dev/201503.mbox/%3C07c401d06aba$0b477c80$21d67580$@thetaphi.de%3E
.

Le ven. 24 nov. 2017 à 15:28, Yonghui Zhao  a écrit :

> Hi,
>
> I clone lucene 4.10.4 tag from github and use ant to build.
>
> My ant and local jdk in mac info:
>
> *Apache Ant(TM) version 1.9.9 compiled on February 2 2017*
> *Trying the default build file: build.xml*
> *Buildfile: /Users/yozhao/src/lucene-solr/lucene/core/build.xml*
> *Detected Java version: 1.7 in:
> /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre*
> *Detected OS: Mac OS X*
>
>
> I use simple one word "ant" command to build the jar, and copy the jar to
> my Centos server.
> Jdk in the server is 1.7.0_67
>
>
> But when I start my service, exception thrown
>
>  20 Exception in thread "main" java.lang.NoSuchMethodError:
> java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
>  21   at
>
> org.apache.lucene.store.ByteBufferIndexInput$SingleBufferImpl.(ByteBufferIndexInput.java:418)
>  22   at
>
> org.apache.lucene.store.ByteBufferIndexInput.newInstance(ByteBufferIndexInput.java:55)
>  23   at
> org.apache.lucene.store.MMapDirectory.openInput(MMapDirectory.java:199)
>  24   at
>
> org.apache.lucene.store.NRTCachingDirectory.openInput(NRTCachingDirectory.java:198)
>  25   at
> org.apache.lucene.store.Directory.openChecksumInput(Directory.java:113)
>  26   at
>
> org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:836)
>  27   at
>
> org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:769)
>
>
>
> This should be some issue with jdk version. I compile in 1.7.0_45 and run
> in 1.7.0_67 why can this happen?
>


Re: Tracking that all query terms are matched in one document

2017-12-04 Thread Michael Sokolov
I'm just saying, that when you form your query, you could also create
another extra query that requires all the terms in the original query, and
then combine it with the original query in a boolean where the original
query is required and the extra query is optional. That will give a boost
when all the terms are found, although I think the scores will be added,
not multiplied.

On Dec 4, 2017 5:22 AM, "Vadim Gindin"  wrote:

> Thanks, Michael!
>
> Yes, I'm sure. Could you explain your proposal in more detail?
>
> Regards,
> Vadim Gindin
>
> On Mon, Dec 4, 2017 at 3:18 PM, Michael Sokolov 
> wrote:
>
> > You could combine a Boolean and query with the same terms, as an optional
> > clause. Are you sure about the requirement to multiply the score in that
> > case?
> >
> > On Dec 4, 2017 5:13 AM, "Vadim Gindin"  wrote:
> >
> > > Hi all.
> > >
> > > I need to track that all query terms are matched in one document. When
> > all
> > > terms are matched I need to multiply the score of such document to some
> > > constant coefficient.
> > >
> >
>


Re: How to regulate native memory?

2017-12-04 Thread Dominique Bejean
Hi Uwe,

When you are saying "MMap is NOT direct memory", I understand that we can
consider that JVM can use (at least) these 3 types of memory:

   - Heap memory (controlled by Xmx and managed by GC)
   - Off-heap MMap (os cache) *which is not* Direct Memory and *is not*
   controlled by MaxDirectMemorySize and *is not* managed by GC
   - Off-heap Direct Memory (off heap) for Direct Byte Buffers and *is*
   controlled by MaxDirectMemorySize and *is not* managed by GC


Solr use Heap memory (of course) and Off-heap MMap but not Off-heap Direct
Memory.

Do you confirm ?

Regards

Dominique



Le jeu. 31 août 2017 à 08:40, Uwe Schindler  a écrit :

> Hi,
>
> As a suggestion from my side: As a first thing: disable the
> bootstrap.memory_lock feature:
> https://www.elastic.co/guide/en/elasticsearch/reference/5.5/important-settings.html#bootstrap.memory_lock
>
> It looks like you are using too much heap space and some plugin in your ES
> installation also using the maximum direct memory size, so I have the
> feeling something is using a lot direct memory and you want to limit that.
> MMap is NOT direct memory! MMap is also not taken into account by the OOM
> killer, because it's not owned by the process.
>
> To me it looks like the operating system kills your process as it sits
> locked on a huge amount of memory. So disable the locking (it is IMHO
> opinion not really useful and too risky). If you also have no swap disk,
> then you may also try to add some swap memory and set systems's swapiness
> to "10" or even lower. In production environments it is better to have a
> little bit of swap as a last resort, but you should tell it with the
> vm.swapiness sysctl that it should only use it as last resort.
>
> Uwe
>
> -
> Uwe Schindler
> Achterdiek 19
> , D-28357
> Bremen
> http://www.thetaphi.de
> eMail: u...@thetaphi.de
>
> > -Original Message-
> > From: Robert Muir [mailto:rcm...@gmail.com]
> > Sent: Thursday, August 31, 2017 6:07 AM
> > To: java-user 
> > Subject: Re: How to regulate native memory?
> >
> > From the lucene side, it only uses file mappings for reads and doesn't
> > allocate any anonymous memory.
> > The way lucene uses cache for reads won't impact your OOM
> > (http://www.linuxatemyram.com/play.html)
> >
> > At the end of the day you are running out of memory on the system
> > either way, and your process might just look like a large target based
> > for the oom-killer, but that doesn't mean its necessarily your problem
> > at all.
> >
> > I advise sticking with basic operating system tools like /proc and
> > free -m, reproduce the OOM kill situation, just like in that example
> > link above, and try to track down the real problem.
> >
> >
> > On Wed, Aug 30, 2017 at 11:43 PM, Erik Stephens
> >  wrote:
> > > Yeah, apologies for that long issue - the netty comments aren't
> related.  My
> > two comments near the end might be more interesting here:
> > >
> > >
> https://github.com/elastic/elasticsearch/issues/26269#issuecomment-
> > 326060213
> > >
> > > To try to summarize, I looked to `/proc/$pid/smaps | grep indices` to
> > quantify what I think is mostly lucene usage.  Is that an accurate way to
> > quantify that?  It shows 51G with `-XX:MaxDirectMemorySize=15G`.  The
> > heap is 30G and the resident memory is reported as 82.5G.  That makes a
> bit
> > of sense: 30G + 51G + miscellaneous.
> > >
> > > `top` reports roughly 51G as shared which is suspiciously close to
> what I'm
> > seeing in /proc/$pid/smaps. Is it correct to think that if a process
> requests
> > memory and there is not enough "free", then the kernel will purge from
> its
> > cache in order to allocate that requested memory?  I'm struggling to see
> how
> > the kernel thinks there isn't enough free memory when so much is in its
> > cache, but that concern is secondary at this point.  My primary concern
> is
> > trying to regulate the overall footprint (shared with file system cache
> or not)
> > so that OOM killer not even part of the conversation in the first place.
> > >
> > > # grep Vm /proc/$pid/status
> > > VmPeak: 982739416 kB
> > > VmSize: 975784980 kB
> > > VmLck: 0 kB
> > > VmPin: 0 kB
> > > VmHWM:  86555044 kB
> > > VmRSS:  86526616 kB
> > > VmData: 42644832 kB
> > > VmStk:   136 kB
> > > VmExe: 4 kB
> > > VmLib: 18028 kB
> > > VmPTE:275292 kB
> > > VmPMD:  3720 kB
> > > VmSwap:0 kB
> > >
> > > # free -g
> > >   totalusedfree  shared  buff/cache
>  available
> > > Mem:125  54   1   1  69
>   69
> > > Swap: 0   0   0
> > >
> > > Thanks for the reply!  Apologies if not apropos to this forum - just
> working
> > my way down the rabbit hole :)
> > >
> > > --
> > > Erik
> > >
> > >
> > >> On Aug 30, 2017, at 8:04 PM, Robert Muir  wrote:
> > >>
> > >> Hello,
> > >>
> > >> From the thread linked t

Re: Tracking that all query terms are matched in one document

2017-12-04 Thread Vadim Gindin
Yes, thanks. My question is exactly about how to create "another extra
query that requires all the terms in the original query"

On Mon, Dec 4, 2017 at 6:50 PM, Michael Sokolov  wrote:

> I'm just saying, that when you form your query, you could also create
> another extra query that requires all the terms in the original query, and
> then combine it with the original query in a boolean where the original
> query is required and the extra query is optional. That will give a boost
> when all the terms are found, although I think the scores will be added,
> not multiplied.
>
> On Dec 4, 2017 5:22 AM, "Vadim Gindin"  wrote:
>
> > Thanks, Michael!
> >
> > Yes, I'm sure. Could you explain your proposal in more detail?
> >
> > Regards,
> > Vadim Gindin
> >
> > On Mon, Dec 4, 2017 at 3:18 PM, Michael Sokolov 
> > wrote:
> >
> > > You could combine a Boolean and query with the same terms, as an
> optional
> > > clause. Are you sure about the requirement to multiply the score in
> that
> > > case?
> > >
> > > On Dec 4, 2017 5:13 AM, "Vadim Gindin"  wrote:
> > >
> > > > Hi all.
> > > >
> > > > I need to track that all query terms are matched in one document.
> When
> > > all
> > > > terms are matched I need to multiply the score of such document to
> some
> > > > constant coefficient.
> > > >
> > >
> >
>


Encryption At Rest - Using CustomAnalyzer

2017-12-04 Thread aravinth thangasami
Hi all,

To support Encryption at Rest, We have written a custom analyzer, that
encrypts every token in the Input string and proceeds to the default
indexing chain

We are using AES/CTR/NoPadding with unique Key Per User.
This helps that the input string with common prefix, the encrypted strings
will also get common prefix
So that we can perform Prefix Query also.

For example,

run   x5X7
runs  x5X7tg==
running x5X7q/nE5g==


During searching, we will preprocess the query for encrypted Field before
searching
we can't do  WildCard & Fuzzy Query


Did anyone try this approach?
Please post your suggestions and your tried approaches


Thanks
Aravinth


Re: Tracking that all query terms are matched in one document

2017-12-04 Thread Michael Sokolov
Well how did you make the original query?

On Dec 4, 2017 12:05 PM, "Vadim Gindin"  wrote:

> Yes, thanks. My question is exactly about how to create "another extra
> query that requires all the terms in the original query"
>
> On Mon, Dec 4, 2017 at 6:50 PM, Michael Sokolov 
> wrote:
>
> > I'm just saying, that when you form your query, you could also create
> > another extra query that requires all the terms in the original query,
> and
> > then combine it with the original query in a boolean where the original
> > query is required and the extra query is optional. That will give a boost
> > when all the terms are found, although I think the scores will be added,
> > not multiplied.
> >
> > On Dec 4, 2017 5:22 AM, "Vadim Gindin"  wrote:
> >
> > > Thanks, Michael!
> > >
> > > Yes, I'm sure. Could you explain your proposal in more detail?
> > >
> > > Regards,
> > > Vadim Gindin
> > >
> > > On Mon, Dec 4, 2017 at 3:18 PM, Michael Sokolov 
> > > wrote:
> > >
> > > > You could combine a Boolean and query with the same terms, as an
> > optional
> > > > clause. Are you sure about the requirement to multiply the score in
> > that
> > > > case?
> > > >
> > > > On Dec 4, 2017 5:13 AM, "Vadim Gindin"  wrote:
> > > >
> > > > > Hi all.
> > > > >
> > > > > I need to track that all query terms are matched in one document.
> > When
> > > > all
> > > > > terms are matched I need to multiply the score of such document to
> > some
> > > > > constant coefficient.
> > > > >
> > > >
> > >
> >
>


Re: Tracking that all query terms are matched in one document

2017-12-04 Thread Vadim Gindin
For example like this:

BooleanQuery.Builder expected = new BooleanQuery.Builder();

Query param_vendor = new BoostQuery(new ConstantScoreQuery(new
TermQuery(new Term("param_vendor", queryStr))), 5f);
Query param_model = new BoostQuery(new ConstantScoreQuery(new
TermQuery(new Term("param_model", queryStr))), 5f);
Query param_value = new BoostQuery(new ConstantScoreQuery(new
TermQuery(new Term("param_value", queryStr))), 3f);
Query param_name = new BoostQuery(new ConstantScoreQuery(new
TermQuery(new Term("param_name", queryStr))), 4f);

BooleanQuery bq = expected
.add(param_vendor, BooleanClause.Occur.SHOULD)
.add(param_model, BooleanClause.Occur.SHOULD)
.add(param_value, BooleanClause.Occur.SHOULD)
.add(param_name, BooleanClause.Occur.SHOULD)
.setMinimumNumberShouldMatch(1)
.build();

return new BoostQuery(bq, queryBoost);


Vadim

On Tue, Dec 5, 2017 at 9:24 AM, Michael Sokolov  wrote:

> Well how did you make the original query?
>
> On Dec 4, 2017 12:05 PM, "Vadim Gindin"  wrote:
>
> > Yes, thanks. My question is exactly about how to create "another extra
> > query that requires all the terms in the original query"
> >
> > On Mon, Dec 4, 2017 at 6:50 PM, Michael Sokolov 
> > wrote:
> >
> > > I'm just saying, that when you form your query, you could also create
> > > another extra query that requires all the terms in the original query,
> > and
> > > then combine it with the original query in a boolean where the original
> > > query is required and the extra query is optional. That will give a
> boost
> > > when all the terms are found, although I think the scores will be
> added,
> > > not multiplied.
> > >
> > > On Dec 4, 2017 5:22 AM, "Vadim Gindin"  wrote:
> > >
> > > > Thanks, Michael!
> > > >
> > > > Yes, I'm sure. Could you explain your proposal in more detail?
> > > >
> > > > Regards,
> > > > Vadim Gindin
> > > >
> > > > On Mon, Dec 4, 2017 at 3:18 PM, Michael Sokolov 
> > > > wrote:
> > > >
> > > > > You could combine a Boolean and query with the same terms, as an
> > > optional
> > > > > clause. Are you sure about the requirement to multiply the score in
> > > that
> > > > > case?
> > > > >
> > > > > On Dec 4, 2017 5:13 AM, "Vadim Gindin" 
> wrote:
> > > > >
> > > > > > Hi all.
> > > > > >
> > > > > > I need to track that all query terms are matched in one document.
> > > When
> > > > > all
> > > > > > terms are matched I need to multiply the score of such document
> to
> > > some
> > > > > > constant coefficient.
> > > > > >
> > > > >
> > > >
> > >
> >
>