[jira] [Comment Edited] (LUCENE-6575) Improve API of PhraseQuery.Builder

2015-06-20 Thread Uwe Schindler (JIRA)

[ 
https://issues.apache.org/jira/browse/LUCENE-6575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14594450#comment-14594450
 ] 

Uwe Schindler edited comment on LUCENE-6575 at 6/20/15 7:12 AM:


I am not sure if we should consider adding a static method 
{{PhraseQuery#builder()}}, which would make building less verbose? For the 
CustomAnalyzer I did this, but people generally have different optinions. - 
same applies for {{BooleanQuery#builder()}}.


was (Author: thetaphi):
I am not sure if we should consider adding a static method 
{{PhraseQuery#builder()}}, which would make building less verbose? For the 
CustomAnalyzer I did this, but people generally have different optinions.

 Improve API of PhraseQuery.Builder
 --

 Key: LUCENE-6575
 URL: https://issues.apache.org/jira/browse/LUCENE-6575
 Project: Lucene - Core
  Issue Type: Improvement
Reporter: Cao Manh Dat
Priority: Minor
 Attachments: LUCENE-6575.patch, LUCENE-6575.patch, LUCENE-6575.patch, 
 LUCENE-6575.patch, LUCENE-6575.patch


 From LUCENE-6531
 In current PhraseQuery.Builder API. User must retype field again and again :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder();
 builder.add(new Term(lyrics, when), 1);
 builder.add(new Term(lyrics, believe), 3);
 {code}
 Cleaner API :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder(lyrics);
 builder.add(when, 1);
 builder.add(believe, 3);
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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



[jira] [Comment Edited] (LUCENE-6575) Improve API of PhraseQuery.Builder

2015-06-18 Thread Cao Manh Dat (JIRA)

[ 
https://issues.apache.org/jira/browse/LUCENE-6575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14591873#comment-14591873
 ] 

Cao Manh Dat edited comment on LUCENE-6575 at 6/18/15 2:32 PM:
---

It quite hard to find such place for this method. Because it appear in serval 
place from QueryParser, StandardQueryParser to QueryParser of Solr.
I agree that we should keep the public APIs as small as possible. But we move 
slop to Builder to make PhraseQuery immutable so it quite appropriate to have a 
new method to clone PhraseQuery with different slop.


was (Author: caomanhdat):
It quite hard to find such place for this method. Because it appear in serval 
place from QueryParser, StandardQueryParser to QueryParser of Solr.
I agree that we should keep the public APIs as small as possible. But we move 
slop to Builder to makePhraseQuery immutable so it quite appropriate to have a 
new method to clone PhraseQuery with different slop.

 Improve API of PhraseQuery.Builder
 --

 Key: LUCENE-6575
 URL: https://issues.apache.org/jira/browse/LUCENE-6575
 Project: Lucene - Core
  Issue Type: Improvement
Reporter: Cao Manh Dat
Priority: Minor
 Attachments: LUCENE-6575.patch, LUCENE-6575.patch, LUCENE-6575.patch


 From LUCENE-6531
 In current PhraseQuery.Builder API. User must retype field again and again :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder();
 builder.add(new Term(lyrics, when), 1);
 builder.add(new Term(lyrics, believe), 3);
 {code}
 Cleaner API :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder(lyrics);
 builder.add(when, 1);
 builder.add(believe, 3);
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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



[jira] [Comment Edited] (LUCENE-6575) Improve API of PhraseQuery.Builder

2015-06-18 Thread Cao Manh Dat (JIRA)

[ 
https://issues.apache.org/jira/browse/LUCENE-6575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14591873#comment-14591873
 ] 

Cao Manh Dat edited comment on LUCENE-6575 at 6/18/15 2:36 PM:
---

It quite hard to find such place for this method. Because it appear in several 
places from QueryParser, StandardQueryParser to QueryParser of Solr.
I agree that we should keep the public APIs as small as possible. But we move 
slop to Builder to make PhraseQuery immutable. So it quite appropriate to have 
a new method to clone PhraseQuery with different slop.


was (Author: caomanhdat):
It quite hard to find such place for this method. Because it appear in serval 
place from QueryParser, StandardQueryParser to QueryParser of Solr.
I agree that we should keep the public APIs as small as possible. But we move 
slop to Builder to make PhraseQuery immutable so it quite appropriate to have a 
new method to clone PhraseQuery with different slop.

 Improve API of PhraseQuery.Builder
 --

 Key: LUCENE-6575
 URL: https://issues.apache.org/jira/browse/LUCENE-6575
 Project: Lucene - Core
  Issue Type: Improvement
Reporter: Cao Manh Dat
Priority: Minor
 Attachments: LUCENE-6575.patch, LUCENE-6575.patch, LUCENE-6575.patch


 From LUCENE-6531
 In current PhraseQuery.Builder API. User must retype field again and again :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder();
 builder.add(new Term(lyrics, when), 1);
 builder.add(new Term(lyrics, believe), 3);
 {code}
 Cleaner API :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder(lyrics);
 builder.add(when, 1);
 builder.add(believe, 3);
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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



[jira] [Comment Edited] (LUCENE-6575) Improve API of PhraseQuery.Builder

2015-06-18 Thread Cao Manh Dat (JIRA)

[ 
https://issues.apache.org/jira/browse/LUCENE-6575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14592091#comment-14592091
 ] 

Cao Manh Dat edited comment on LUCENE-6575 at 6/18/15 4:54 PM:
---

I agree that we should change implementation of QueryParser in the future. For 
now, the duplication in QueryParsers is recreate PhraseQuery with new slop. So 
I think it's a necessary and nicely feature of immutable PhraseQuery instance!


was (Author: caomanhdat):
I agree that we should change implementation of QueryParser in the future. For 
now, the duplication in QueryParsers is recreate PhraseQuery with new slop. So 
I think it's a necessary and nicely feature of PhraseQuery instance!

 Improve API of PhraseQuery.Builder
 --

 Key: LUCENE-6575
 URL: https://issues.apache.org/jira/browse/LUCENE-6575
 Project: Lucene - Core
  Issue Type: Improvement
Reporter: Cao Manh Dat
Priority: Minor
 Attachments: LUCENE-6575.patch, LUCENE-6575.patch, LUCENE-6575.patch


 From LUCENE-6531
 In current PhraseQuery.Builder API. User must retype field again and again :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder();
 builder.add(new Term(lyrics, when), 1);
 builder.add(new Term(lyrics, believe), 3);
 {code}
 Cleaner API :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder(lyrics);
 builder.add(when, 1);
 builder.add(believe, 3);
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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



[jira] [Comment Edited] (LUCENE-6575) Improve API of PhraseQuery.Builder

2015-06-18 Thread Cao Manh Dat (JIRA)

[ 
https://issues.apache.org/jira/browse/LUCENE-6575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14592091#comment-14592091
 ] 

Cao Manh Dat edited comment on LUCENE-6575 at 6/18/15 4:54 PM:
---

I agree that we should change implementation of QueryParser in the future. For 
now, the duplication in QueryParsers is recreate PhraseQuery with new slop. So 
I think it's a necessary and nicely feature of PhraseQuery instance!


was (Author: caomanhdat):
I agree that we should change implementation of QueryParser in the future. For 
now, the duplication in QueryParsers is recreate PhraseQuery with new slop. So 
It is a necessary feature of PhraseQuery instance!

 Improve API of PhraseQuery.Builder
 --

 Key: LUCENE-6575
 URL: https://issues.apache.org/jira/browse/LUCENE-6575
 Project: Lucene - Core
  Issue Type: Improvement
Reporter: Cao Manh Dat
Priority: Minor
 Attachments: LUCENE-6575.patch, LUCENE-6575.patch, LUCENE-6575.patch


 From LUCENE-6531
 In current PhraseQuery.Builder API. User must retype field again and again :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder();
 builder.add(new Term(lyrics, when), 1);
 builder.add(new Term(lyrics, believe), 3);
 {code}
 Cleaner API :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder(lyrics);
 builder.add(when, 1);
 builder.add(believe, 3);
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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



[jira] [Comment Edited] (LUCENE-6575) Improve API of PhraseQuery.Builder

2015-06-18 Thread Cao Manh Dat (JIRA)

[ 
https://issues.apache.org/jira/browse/LUCENE-6575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14592841#comment-14592841
 ] 

Cao Manh Dat edited comment on LUCENE-6575 at 6/19/15 1:26 AM:
---

It quite clear now. I will move the method to QueryBuilder.and think about what 
we can do to make QueryParser clearer with new Builders afterwards. Thanks 
[~jpountz].


was (Author: caomanhdat):
It quite clear now. I will move the method to QueryBuilder.and what we can do 
to make QueryParser clearer with new Builders afterwards. Thanks [~jpountz].

 Improve API of PhraseQuery.Builder
 --

 Key: LUCENE-6575
 URL: https://issues.apache.org/jira/browse/LUCENE-6575
 Project: Lucene - Core
  Issue Type: Improvement
Reporter: Cao Manh Dat
Priority: Minor
 Attachments: LUCENE-6575.patch, LUCENE-6575.patch, LUCENE-6575.patch, 
 LUCENE-6575.patch


 From LUCENE-6531
 In current PhraseQuery.Builder API. User must retype field again and again :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder();
 builder.add(new Term(lyrics, when), 1);
 builder.add(new Term(lyrics, believe), 3);
 {code}
 Cleaner API :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder(lyrics);
 builder.add(when, 1);
 builder.add(believe, 3);
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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



[jira] [Comment Edited] (LUCENE-6575) Improve API of PhraseQuery.Builder

2015-06-17 Thread Cao Manh Dat (JIRA)

[ 
https://issues.apache.org/jira/browse/LUCENE-6575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14589627#comment-14589627
 ] 

Cao Manh Dat edited comment on LUCENE-6575 at 6/17/15 11:11 AM:


Thanks Robert,Andrien and Uwe. I will submit a patch in couple of hours.


was (Author: caomanhdat):
Thanks Robert and Andrien. I will submit a patch in couple of hours.

 Improve API of PhraseQuery.Builder
 --

 Key: LUCENE-6575
 URL: https://issues.apache.org/jira/browse/LUCENE-6575
 Project: Lucene - Core
  Issue Type: Improvement
Reporter: Cao Manh Dat
Priority: Minor
 Attachments: LUCENE-6575.patch, LUCENE-6575.patch


 From LUCENE-6531
 In current PhraseQuery.Builder API. User must retype field again and again :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder();
 builder.add(new Term(lyrics, when), 1);
 builder.add(new Term(lyrics, believe), 3);
 {code}
 Cleaner API :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder(lyrics);
 builder.add(when, 1);
 builder.add(believe, 3);
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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



[jira] [Comment Edited] (LUCENE-6575) Improve API of PhraseQuery.Builder

2015-06-17 Thread Cao Manh Dat (JIRA)

[ 
https://issues.apache.org/jira/browse/LUCENE-6575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14589441#comment-14589441
 ] 

Cao Manh Dat edited comment on LUCENE-6575 at 6/17/15 7:52 AM:
---

[~jpountz] Thanks you for you comment. 
- I agree that chaining in builder make it quite hard to read. I will fix that 
soon.
- About two new constructors of Builder. Currently, PhraseQuery act as 
BooleanQuery some times (it rely on terms.length() == 0 to rewrite to 
BooleanQuery). So consumer will not have to care about their terms[] is empty 
or not, they simply deliver it to PhraseQuery. If we remove these constructors 
of Builder, consumer will have to check it terms[] size and do the same thing. 
Is it approciate?


was (Author: caomanhdat):
[~jpountz] Thanks you for you comment. 
- I agree that chaining in builder make it quite hard to read. I will fix that 
soon.
- About two new constructors of Builder. Currently, PhraseQuery act as 
BooleanQuery some times (it rely terms.length() == 0 to rewrite to 
BooleanQuery). So consumer will not have to care about their terms[] is empty 
or not, they simply deliver it to PhraseQuery. If we remove these constructors 
of Builder, consumer will have to check it terms[] size and do the same thing. 
Is it approciate?

 Improve API of PhraseQuery.Builder
 --

 Key: LUCENE-6575
 URL: https://issues.apache.org/jira/browse/LUCENE-6575
 Project: Lucene - Core
  Issue Type: Improvement
Reporter: Cao Manh Dat
Priority: Minor
 Attachments: LUCENE-6575.patch, LUCENE-6575.patch


 From LUCENE-6531
 In current PhraseQuery.Builder API. User must retype field again and again :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder();
 builder.add(new Term(lyrics, when), 1);
 builder.add(new Term(lyrics, believe), 3);
 {code}
 Cleaner API :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder(lyrics);
 builder.add(when, 1);
 builder.add(believe, 3);
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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



[jira] [Comment Edited] (LUCENE-6575) Improve API of PhraseQuery.Builder

2015-06-17 Thread Uwe Schindler (JIRA)

[ 
https://issues.apache.org/jira/browse/LUCENE-6575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14589490#comment-14589490
 ] 

Uwe Schindler edited comment on LUCENE-6575 at 6/17/15 8:40 AM:


bq. We are not there yet, but please let's not put this chaining issue in the 
way of making our queries immutable.

This issue was about improving the API, so it is relevant here. I think making 
phrase queries immutable is another thing and was discussed in LUCENE-6531.

bq. And since Cao changed the setters to return this in his patch, I pointed 
him to this previous discussion.

Robert's main problem was not the chaining, he disagreed with the fluent 
method names (Java 8+ streams API is using them everywhere now)!

But just returning this from a setter is in my opinion a valid simplification 
for users of the API. It mainly works around the problem of not having a with 
operator in java, like Javascript has: 

{code:javascript}
with (object) {
 setA();
 setB();
}
{code}

On the Java side, recent versions of Eclipse perfectly detect  ident those 
chaining constructs (because Java 8 requires them to do this, otherwise code 
gets indeed unreadable).

I also added builder APIs in recently: {{CustomAnalyzer.builder()}} (see my 
talk @ buzzwords; 
http://lucene.apache.org/core/5_2_1/analyzers-common/org/apache/lucene/analysis/custom/CustomAnalyzer.html)
 and Robert did not complain, because the names were according to fluent API 
standard and the formatting in the tests was also fine :-)


was (Author: thetaphi):
bq. We are not there yet, but please let's not put this chaining issue in the 
way of making our queries immutable.

This issue was about improving the API, so it is relevant here. I think making 
phrase queries immutable is another thing and was discussed in LUCENE-6531.

bq. And since Cao changed the setters to return this in his patch, I pointed 
him to this previous discussion.

Robert's main problem was not the chaining, he disagreed with the fluent 
method names (Java 8+ streams API is using them everywhere now)!

But just returning this from a setter is in my opinion a valid simplification 
for users of the API. It mainly works around the problem of not having a with 
operator in java, like Javascript has: 

{code:javascript}
with (object) {
 setA();
 setB();
}
{code}

On the Java side, recent versions of Eclipse perfectly detect  ident those 
chaining constructs (because Java 8 requires them to do this, otherwise code 
gets indeed unreadable).

I also added builder APIs in recently: {{CustomAnalyzer.builder()}} (see my 
talk @ buzzwords) and Robert did not complain, because the names were according 
to fluent API standard and the formatting in the tests was also fine :-)

 Improve API of PhraseQuery.Builder
 --

 Key: LUCENE-6575
 URL: https://issues.apache.org/jira/browse/LUCENE-6575
 Project: Lucene - Core
  Issue Type: Improvement
Reporter: Cao Manh Dat
Priority: Minor
 Attachments: LUCENE-6575.patch, LUCENE-6575.patch


 From LUCENE-6531
 In current PhraseQuery.Builder API. User must retype field again and again :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder();
 builder.add(new Term(lyrics, when), 1);
 builder.add(new Term(lyrics, believe), 3);
 {code}
 Cleaner API :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder(lyrics);
 builder.add(when, 1);
 builder.add(believe, 3);
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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



[jira] [Comment Edited] (LUCENE-6575) Improve API of PhraseQuery.Builder

2015-06-17 Thread Uwe Schindler (JIRA)

[ 
https://issues.apache.org/jira/browse/LUCENE-6575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14589490#comment-14589490
 ] 

Uwe Schindler edited comment on LUCENE-6575 at 6/17/15 8:38 AM:


bq. We are not there yet, but please let's not put this chaining issue in the 
way of making our queries immutable.

This issue was about improving the API, so it is relevant here. I think making 
phrase queries immutable is another thing and was discussed in LUCENE-6531.

bq. And since Cao changed the setters to return this in his patch, I pointed 
him to this previous discussion.

Robert's main problem was not the chaining, he disagreed with the fluent 
method names (Java 8+ streams API is using them everywhere now)!

But just returning this from a setter is in my opinion a valid simplification 
for users of the API. It mainly works around the problem of not having a with 
operator in java, like Javascript has: 

{code:javascript}
with (object) {
 setA();
 setB();
}
{code}

On the Java side, recent versions of Eclipse perfectly detect  ident those 
chaining constructs (because Java 8 requires them to do this, otherwise code 
gets indeed unreadable).

I also added builder APIs in recently: {{CustomAnalyzer.builder()}} (see my 
talk @ buzzwords) and Robert did not complain, because the names were according 
to fluent API standard and the formatting in the tests was also fine :-)


was (Author: thetaphi):
bq. We are not there yet, but please let's not put this chaining issue in the 
way of making our queries immutable.

This issue was about improving the API, so it is relevant here. I think making 
phrase queries immutable is another thing and was discussed in LUCENE-6531.

bq. And since Cao changed the setters to return this in his patch, I pointed 
him to this previous discussion.

Robert's main problem was not the chaining, he disagreed with the fluent 
method names (Java 8+ streams API is using them everywhere now)!

But just returning this from a setter is in my opinion a valid simplification 
for users of the API. It mainly works around the problem of not having a with 
operator in java, like Javascript has: 

{code:javascript}
with (object) {
 setA();
 setB();
}
{code}

And recent versions of Eclipse perfectly detect  ident those constructs 
(because Java 8 requires them to do this, otherwise code gets indeed 
unreadable).

I also added builder APIs in recently: {{CustomAnalyzer.builder()}} (see my 
talk @ buzzwords) and Robert did not complain, because the names were according 
to fluent API standard and the formatting in the tests was also fine :-)

 Improve API of PhraseQuery.Builder
 --

 Key: LUCENE-6575
 URL: https://issues.apache.org/jira/browse/LUCENE-6575
 Project: Lucene - Core
  Issue Type: Improvement
Reporter: Cao Manh Dat
Priority: Minor
 Attachments: LUCENE-6575.patch, LUCENE-6575.patch


 From LUCENE-6531
 In current PhraseQuery.Builder API. User must retype field again and again :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder();
 builder.add(new Term(lyrics, when), 1);
 builder.add(new Term(lyrics, believe), 3);
 {code}
 Cleaner API :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder(lyrics);
 builder.add(when, 1);
 builder.add(believe, 3);
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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



[jira] [Comment Edited] (LUCENE-6575) Improve API of PhraseQuery.Builder

2015-06-17 Thread Cao Manh Dat (JIRA)

[ 
https://issues.apache.org/jira/browse/LUCENE-6575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14589847#comment-14589847
 ] 

Cao Manh Dat edited comment on LUCENE-6575 at 6/17/15 2:33 PM:
---

Here is the patch based on suggestions. Because I found a lot of place do the 
same thing below
{code}
PhraseQuery pq = (PhraseQuery) query;
Term[] terms = pq.getTerms();
int[] positions = pq.getPositions();
PhraseQuery.Builder builder = new PhraseQuery.Builder();
for (int i = 0; i  terms.length; ++i) {
  builder.add(terms[i], positions[i]);
}
builder.setSlop(slop);
query = builder.build();
query.setBoost(pq.getBoost());
{code}
So i added a new Builder(PhraseQuery pq) constructor to reduce repeated works.


was (Author: caomanhdat):
Here is the patch based on suggestions. Because I found a lot of place do the 
same thing below
{code}
PhraseQuery pq = (PhraseQuery) query;
Term[] terms = pq.getTerms();
int[] positions = pq.getPositions();
PhraseQuery.Builder builder = new PhraseQuery.Builder();
for (int i = 0; i  terms.length; ++i) {
  builder.add(terms[i], positions[i]);
}
builder.setSlop(slop);
query = builder.build();
query.setBoost(pq.getBoost());
{code}
So i added a new Builder(PhraseQuery pq) constructor.

 Improve API of PhraseQuery.Builder
 --

 Key: LUCENE-6575
 URL: https://issues.apache.org/jira/browse/LUCENE-6575
 Project: Lucene - Core
  Issue Type: Improvement
Reporter: Cao Manh Dat
Priority: Minor
 Attachments: LUCENE-6575.patch, LUCENE-6575.patch, LUCENE-6575.patch


 From LUCENE-6531
 In current PhraseQuery.Builder API. User must retype field again and again :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder();
 builder.add(new Term(lyrics, when), 1);
 builder.add(new Term(lyrics, believe), 3);
 {code}
 Cleaner API :
 {code}
 PhraseQuery.Builder builder = new PhraseQuery.Builder(lyrics);
 builder.add(when, 1);
 builder.add(believe, 3);
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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