a query for a special AND?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

a query for a special AND?

is_maximum
Hi
I have a problem in getting correct result from Lucene, consider we have an
index containing documents with fields "field1" and "field2" etc. now I want
to have documents in which their field1 are equal one by one and their
field2 with two different value

to clarify consider I have this query:
field1:val*  (field2:"myValue1" XOR field2:"myValue2")

now I want this result:
field1              field2
val1                myValue1
val1                myValue2
val2                myValue1
val2                myValue2

this result is not acceptable:
val3              myValue1
or
val4             myValue1
val4             myValue3

I put XOR as operator because this is not a typical OR, it's different, it
means documents that contains both myValue1 and myValue2 for the field
field2

how to build a query to get such result?

thanks in advance
--
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
another in Persian: http://fekre-motefavet.blogspot.com/
Sun Certified Java Programmer
ExpertsExchange Certified, Master:
http://www.experts-exchange.com/M_1938796.html
--
Regards
Mohammad
Pixelshot
Reply | Threaded
Open this post in threaded view
|

Re: a query for a special AND?

Paul Elschot
On Monday 17 September 2007 11:40, Mohammad Norouzi wrote:
> Hi
> I have a problem in getting correct result from Lucene, consider we have an
> index containing documents with fields "field1" and "field2" etc. now I want
> to have documents in which their field1 are equal one by one and their
> field2 with two different value
>
> to clarify consider I have this query:
> field1:val*  (field2:"myValue1" XOR field2:"myValue2")

Did you try this:

+field1:val*  +field2:"myValue1" +field2:"myValue2"

Regards,
Paul Elschot


>
> now I want this result:
> field1              field2
> val1                myValue1
> val1                myValue2
> val2                myValue1
> val2                myValue2
>
> this result is not acceptable:
> val3              myValue1
> or
> val4             myValue1
> val4             myValue3
>
> I put XOR as operator because this is not a typical OR, it's different, it
> means documents that contains both myValue1 and myValue2 for the field
> field2
>
> how to build a query to get such result?
>
> thanks in advance
> --
> Regards,
> Mohammad
> --------------------------
> see my blog: http://brainable.blogspot.com/
> another in Persian: http://fekre-motefavet.blogspot.com/
> Sun Certified Java Programmer
> ExpertsExchange Certified, Master:
> http://www.experts-exchange.com/M_1938796.html
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: a query for a special AND?

is_maximum
Hi Paul,
would you tell me what is the difference between AND and + ?
I tried both but get different result
with AND I get 1777 documents and with + I get nearly 25000 ?


On 9/17/07, Paul Elschot <[hidden email]> wrote:

>
> On Monday 17 September 2007 11:40, Mohammad Norouzi wrote:
> > Hi
> > I have a problem in getting correct result from Lucene, consider we have
> an
> > index containing documents with fields "field1" and "field2" etc. now I
> want
> > to have documents in which their field1 are equal one by one and their
> > field2 with two different value
> >
> > to clarify consider I have this query:
> > field1:val*  (field2:"myValue1" XOR field2:"myValue2")
>
> Did you try this:
>
> +field1:val*  +field2:"myValue1" +field2:"myValue2"
>
> Regards,
> Paul Elschot
>
>
> >
> > now I want this result:
> > field1              field2
> > val1                myValue1
> > val1                myValue2
> > val2                myValue1
> > val2                myValue2
> >
> > this result is not acceptable:
> > val3              myValue1
> > or
> > val4             myValue1
> > val4             myValue3
> >
> > I put XOR as operator because this is not a typical OR, it's different,
> it
> > means documents that contains both myValue1 and myValue2 for the field
> > field2
> >
> > how to build a query to get such result?
> >
> > thanks in advance
> > --
> > Regards,
> > Mohammad
> > --------------------------
> > see my blog: http://brainable.blogspot.com/
> > another in Persian: http://fekre-motefavet.blogspot.com/
> > Sun Certified Java Programmer
> > ExpertsExchange Certified, Master:
> > http://www.experts-exchange.com/M_1938796.html
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
another in Persian: http://fekre-motefavet.blogspot.com/
Sun Certified Java Programmer
ExpertsExchange Certified, Master:
http://www.experts-exchange.com/M_1938796.html
--
Regards
Mohammad
Pixelshot
Reply | Threaded
Open this post in threaded view
|

Re: a query for a special AND?

is_maximum
Sorry Paul I just hurried in replying ;)
I read the documents of Lucene about query syntax and I figured out the what
is the difference
but my problem is different, this is preoccupied my mind and I am under
pressure to solve this problem, after analyzing the results I get, now I
think we need a "group by" in our query.

let me tell you an example: we need a list of patients that have been
examined by certain services specified by the user , say service one and
service two.

in this case here is the correct result:
patient-id              service_name               patient_result
1                             s1                                12
1                             s2                                13
2                             s1                                  41
2                             s2                                22

but for example, following is incorrect because patient 1 has no service
with name service2:
patient-id              service_name               patient_result
1                             s1                                12
1                             s3                                13



On 9/20/07, Mohammad Norouzi <[hidden email]> wrote:

>
> Hi Paul,
> would you tell me what is the difference between AND and + ?
> I tried both but get different result
> with AND I get 1777 documents and with + I get nearly 25000 ?
>
>
> On 9/17/07, Paul Elschot <[hidden email]> wrote:
> >
> > On Monday 17 September 2007 11:40, Mohammad Norouzi wrote:
> > > Hi
> > > I have a problem in getting correct result from Lucene, consider we
> > have an
> > > index containing documents with fields "field1" and "field2" etc. now
> > I want
> > > to have documents in which their field1 are equal one by one and their
> > > field2 with two different value
> > >
> > > to clarify consider I have this query:
> > > field1:val*  (field2:"myValue1" XOR field2:"myValue2")
> >
> > Did you try this:
> >
> > +field1:val*  +field2:"myValue1" +field2:"myValue2"
> >
> > Regards,
> > Paul Elschot
> >
> >
> > >
> > > now I want this result:
> > > field1              field2
> > > val1                myValue1
> > > val1                myValue2
> > > val2                myValue1
> > > val2                myValue2
> > >
> > > this result is not acceptable:
> > > val3              myValue1
> > > or
> > > val4             myValue1
> > > val4             myValue3
> > >
> > > I put XOR as operator because this is not a typical OR, it's
> > different, it
> > > means documents that contains both myValue1 and myValue2 for the field
> >
> > > field2
> > >
> > > how to build a query to get such result?
> > >
> > > thanks in advance
> > > --
> > > Regards,
> > > Mohammad
> > > --------------------------
> > > see my blog: http://brainable.blogspot.com/
> > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > Sun Certified Java Programmer
> > > ExpertsExchange Certified, Master:
> > > http://www.experts-exchange.com/M_1938796.html
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
>
> --
> Regards,
> Mohammad
> --------------------------
> see my blog: http://brainable.blogspot.com/
> another in Persian: http://fekre-motefavet.blogspot.com/
> Sun Certified Java Programmer
> ExpertsExchange Certified, Master: http://www.experts-exchange.com/M_1938796.html
>
>



--
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
another in Persian: http://fekre-motefavet.blogspot.com/
Sun Certified Java Programmer
ExpertsExchange Certified, Master:
http://www.experts-exchange.com/M_1938796.html
--
Regards
Mohammad
Pixelshot
Reply | Threaded
Open this post in threaded view
|

Re: a query for a special AND?

Paul Elschot
On Thursday 20 September 2007 07:29, Mohammad Norouzi wrote:

> Sorry Paul I just hurried in replying ;)
> I read the documents of Lucene about query syntax and I figured out the what
> is the difference
> but my problem is different, this is preoccupied my mind and I am under
> pressure to solve this problem, after analyzing the results I get, now I
> think we need a "group by" in our query.
>
> let me tell you an example: we need a list of patients that have been
> examined by certain services specified by the user , say service one and
> service two.
>
> in this case here is the correct result:
> patient-id              service_name               patient_result
> 1                             s1                                12
> 1                             s2                                13
> 2                             s1                                  41
> 2                             s2                                22
>
> but for example, following is incorrect because patient 1 has no service
> with name service2:
> patient-id              service_name               patient_result
> 1                             s1                                12
> 1                             s3                                13

That depends on what you put in your lucene documents.
You can only get complete lucene documents as query results.
For the above example a patient with all service names
should be indexed in a single lucene doc.

The rows above suggest that the relation between patient and
service forms the relational result. However, for a text search
engine it is usual to denormalize the relational records into
indexed documents, depending on the required output.

Regards,
Paul Elschot



>
>
>
> On 9/20/07, Mohammad Norouzi <[hidden email]> wrote:
> >
> > Hi Paul,
> > would you tell me what is the difference between AND and + ?
> > I tried both but get different result
> > with AND I get 1777 documents and with + I get nearly 25000 ?
> >
> >
> > On 9/17/07, Paul Elschot <[hidden email]> wrote:
> > >
> > > On Monday 17 September 2007 11:40, Mohammad Norouzi wrote:
> > > > Hi
> > > > I have a problem in getting correct result from Lucene, consider we
> > > have an
> > > > index containing documents with fields "field1" and "field2" etc. now
> > > I want
> > > > to have documents in which their field1 are equal one by one and their
> > > > field2 with two different value
> > > >
> > > > to clarify consider I have this query:
> > > > field1:val*  (field2:"myValue1" XOR field2:"myValue2")
> > >
> > > Did you try this:
> > >
> > > +field1:val*  +field2:"myValue1" +field2:"myValue2"
> > >
> > > Regards,
> > > Paul Elschot
> > >
> > >
> > > >
> > > > now I want this result:
> > > > field1              field2
> > > > val1                myValue1
> > > > val1                myValue2
> > > > val2                myValue1
> > > > val2                myValue2
> > > >
> > > > this result is not acceptable:
> > > > val3              myValue1
> > > > or
> > > > val4             myValue1
> > > > val4             myValue3
> > > >
> > > > I put XOR as operator because this is not a typical OR, it's
> > > different, it
> > > > means documents that contains both myValue1 and myValue2 for the field
> > >
> > > > field2
> > > >
> > > > how to build a query to get such result?
> > > >
> > > > thanks in advance
> > > > --
> > > > Regards,
> > > > Mohammad
> > > > --------------------------
> > > > see my blog: http://brainable.blogspot.com/
> > > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > > Sun Certified Java Programmer
> > > > ExpertsExchange Certified, Master:
> > > > http://www.experts-exchange.com/M_1938796.html
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden email]
> > > For additional commands, e-mail: [hidden email]
> > >
> > >
> >
> >
> > --
> > Regards,
> > Mohammad
> > --------------------------
> > see my blog: http://brainable.blogspot.com/
> > another in Persian: http://fekre-motefavet.blogspot.com/
> > Sun Certified Java Programmer
> > ExpertsExchange Certified, Master:
http://www.experts-exchange.com/M_1938796.html

> >
> >
>
>
>
> --
> Regards,
> Mohammad
> --------------------------
> see my blog: http://brainable.blogspot.com/
> another in Persian: http://fekre-motefavet.blogspot.com/
> Sun Certified Java Programmer
> ExpertsExchange Certified, Master:
> http://www.experts-exchange.com/M_1938796.html
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: a query for a special AND?

is_maximum
well, you mean we should separate documents just like relational tables in
databases ?
if yes, how to make the relationship between those documents

thank you so much Paul

On 9/20/07, Paul Elschot <[hidden email]> wrote:

>
> On Thursday 20 September 2007 07:29, Mohammad Norouzi wrote:
> > Sorry Paul I just hurried in replying ;)
> > I read the documents of Lucene about query syntax and I figured out the
> what
> > is the difference
> > but my problem is different, this is preoccupied my mind and I am under
> > pressure to solve this problem, after analyzing the results I get, now I
> > think we need a "group by" in our query.
> >
> > let me tell you an example: we need a list of patients that have been
> > examined by certain services specified by the user , say service one and
> > service two.
> >
> > in this case here is the correct result:
> > patient-id              service_name               patient_result
> > 1                             s1                                12
> > 1                             s2                                13
> > 2                             s1                                  41
> > 2                             s2                                22
> >
> > but for example, following is incorrect because patient 1 has no service
> > with name service2:
> > patient-id              service_name               patient_result
> > 1                             s1                                12
> > 1                             s3                                13
>
> That depends on what you put in your lucene documents.
> You can only get complete lucene documents as query results.
> For the above example a patient with all service names
> should be indexed in a single lucene doc.
>
> The rows above suggest that the relation between patient and
> service forms the relational result. However, for a text search
> engine it is usual to denormalize the relational records into
> indexed documents, depending on the required output.
>
> Regards,
> Paul Elschot
>
>
>
> >
> >
> >
> > On 9/20/07, Mohammad Norouzi <[hidden email]> wrote:
> > >
> > > Hi Paul,
> > > would you tell me what is the difference between AND and + ?
> > > I tried both but get different result
> > > with AND I get 1777 documents and with + I get nearly 25000 ?
> > >
> > >
> > > On 9/17/07, Paul Elschot <[hidden email]> wrote:
> > > >
> > > > On Monday 17 September 2007 11:40, Mohammad Norouzi wrote:
> > > > > Hi
> > > > > I have a problem in getting correct result from Lucene, consider
> we
> > > > have an
> > > > > index containing documents with fields "field1" and "field2" etc.
> now
> > > > I want
> > > > > to have documents in which their field1 are equal one by one and
> their
> > > > > field2 with two different value
> > > > >
> > > > > to clarify consider I have this query:
> > > > > field1:val*  (field2:"myValue1" XOR field2:"myValue2")
> > > >
> > > > Did you try this:
> > > >
> > > > +field1:val*  +field2:"myValue1" +field2:"myValue2"
> > > >
> > > > Regards,
> > > > Paul Elschot
> > > >
> > > >
> > > > >
> > > > > now I want this result:
> > > > > field1              field2
> > > > > val1                myValue1
> > > > > val1                myValue2
> > > > > val2                myValue1
> > > > > val2                myValue2
> > > > >
> > > > > this result is not acceptable:
> > > > > val3              myValue1
> > > > > or
> > > > > val4             myValue1
> > > > > val4             myValue3
> > > > >
> > > > > I put XOR as operator because this is not a typical OR, it's
> > > > different, it
> > > > > means documents that contains both myValue1 and myValue2 for the
> field
> > > >
> > > > > field2
> > > > >
> > > > > how to build a query to get such result?
> > > > >
> > > > > thanks in advance
> > > > > --
> > > > > Regards,
> > > > > Mohammad
> > > > > --------------------------
> > > > > see my blog: http://brainable.blogspot.com/
> > > > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > > > Sun Certified Java Programmer
> > > > > ExpertsExchange Certified, Master:
> > > > > http://www.experts-exchange.com/M_1938796.html
> > > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [hidden email]
> > > > For additional commands, e-mail: [hidden email]
> > > >
> > > >
> > >
> > >
> > > --
> > > Regards,
> > > Mohammad
> > > --------------------------
> > > see my blog: http://brainable.blogspot.com/
> > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > Sun Certified Java Programmer
> > > ExpertsExchange Certified, Master:
> http://www.experts-exchange.com/M_1938796.html
> > >
> > >
> >
> >
> >
> > --
> > Regards,
> > Mohammad
> > --------------------------
> > see my blog: http://brainable.blogspot.com/
> > another in Persian: http://fekre-motefavet.blogspot.com/
> > Sun Certified Java Programmer
> > ExpertsExchange Certified, Master:
> > http://www.experts-exchange.com/M_1938796.html
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
another in Persian: http://fekre-motefavet.blogspot.com/
Sun Certified Java Programmer
ExpertsExchange Certified, Master:
http://www.experts-exchange.com/M_1938796.html
--
Regards
Mohammad
Pixelshot
Reply | Threaded
Open this post in threaded view
|

Re: a query for a special AND?

Paul Elschot
On Thursday 20 September 2007 09:19, Mohammad Norouzi wrote:
> well, you mean we should separate documents just like relational tables in
> databases ?

Quite the contrary, it's called _de_normalization. This means that the
documents in lucene normally contain more information than is present
in a single relational entity.

> if yes, how to make the relationship between those documents

Lucene has no facilities to maintain relational relationships among
its documents. A lucene index allows free format documents, i.e.
any document may have any field or not.
In practice you will need at least a primary key, but even that you will
need to program yourself.

Regards,
Paul Elschot



>
> thank you so much Paul
>
> On 9/20/07, Paul Elschot <[hidden email]> wrote:
> >
> > On Thursday 20 September 2007 07:29, Mohammad Norouzi wrote:
> > > Sorry Paul I just hurried in replying ;)
> > > I read the documents of Lucene about query syntax and I figured out the
> > what
> > > is the difference
> > > but my problem is different, this is preoccupied my mind and I am under
> > > pressure to solve this problem, after analyzing the results I get, now I
> > > think we need a "group by" in our query.
> > >
> > > let me tell you an example: we need a list of patients that have been
> > > examined by certain services specified by the user , say service one and
> > > service two.
> > >
> > > in this case here is the correct result:
> > > patient-id              service_name               patient_result
> > > 1                             s1                                12
> > > 1                             s2                                13
> > > 2                             s1                                  41
> > > 2                             s2                                22
> > >
> > > but for example, following is incorrect because patient 1 has no service
> > > with name service2:
> > > patient-id              service_name               patient_result
> > > 1                             s1                                12
> > > 1                             s3                                13
> >
> > That depends on what you put in your lucene documents.
> > You can only get complete lucene documents as query results.
> > For the above example a patient with all service names
> > should be indexed in a single lucene doc.
> >
> > The rows above suggest that the relation between patient and
> > service forms the relational result. However, for a text search
> > engine it is usual to denormalize the relational records into
> > indexed documents, depending on the required output.
> >
> > Regards,
> > Paul Elschot
> >
> >
> >
> > >
> > >
> > >
> > > On 9/20/07, Mohammad Norouzi <[hidden email]> wrote:
> > > >
> > > > Hi Paul,
> > > > would you tell me what is the difference between AND and + ?
> > > > I tried both but get different result
> > > > with AND I get 1777 documents and with + I get nearly 25000 ?
> > > >
> > > >
> > > > On 9/17/07, Paul Elschot <[hidden email]> wrote:
> > > > >
> > > > > On Monday 17 September 2007 11:40, Mohammad Norouzi wrote:
> > > > > > Hi
> > > > > > I have a problem in getting correct result from Lucene, consider
> > we
> > > > > have an
> > > > > > index containing documents with fields "field1" and "field2" etc.
> > now
> > > > > I want
> > > > > > to have documents in which their field1 are equal one by one and
> > their
> > > > > > field2 with two different value
> > > > > >
> > > > > > to clarify consider I have this query:
> > > > > > field1:val*  (field2:"myValue1" XOR field2:"myValue2")
> > > > >
> > > > > Did you try this:
> > > > >
> > > > > +field1:val*  +field2:"myValue1" +field2:"myValue2"
> > > > >
> > > > > Regards,
> > > > > Paul Elschot
> > > > >
> > > > >
> > > > > >
> > > > > > now I want this result:
> > > > > > field1              field2
> > > > > > val1                myValue1
> > > > > > val1                myValue2
> > > > > > val2                myValue1
> > > > > > val2                myValue2
> > > > > >
> > > > > > this result is not acceptable:
> > > > > > val3              myValue1
> > > > > > or
> > > > > > val4             myValue1
> > > > > > val4             myValue3
> > > > > >
> > > > > > I put XOR as operator because this is not a typical OR, it's
> > > > > different, it
> > > > > > means documents that contains both myValue1 and myValue2 for the
> > field
> > > > >
> > > > > > field2
> > > > > >
> > > > > > how to build a query to get such result?
> > > > > >
> > > > > > thanks in advance
> > > > > > --
> > > > > > Regards,
> > > > > > Mohammad
> > > > > > --------------------------
> > > > > > see my blog: http://brainable.blogspot.com/
> > > > > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > > > > Sun Certified Java Programmer
> > > > > > ExpertsExchange Certified, Master:
> > > > > > http://www.experts-exchange.com/M_1938796.html
> > > > > >
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: [hidden email]
> > > > > For additional commands, e-mail: [hidden email]
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Regards,
> > > > Mohammad
> > > > --------------------------
> > > > see my blog: http://brainable.blogspot.com/
> > > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > > Sun Certified Java Programmer
> > > > ExpertsExchange Certified, Master:
> > http://www.experts-exchange.com/M_1938796.html
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Regards,
> > > Mohammad
> > > --------------------------
> > > see my blog: http://brainable.blogspot.com/
> > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > Sun Certified Java Programmer
> > > ExpertsExchange Certified, Master:
> > > http://www.experts-exchange.com/M_1938796.html
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
>
> --
> Regards,
> Mohammad
> --------------------------
> see my blog: http://brainable.blogspot.com/
> another in Persian: http://fekre-motefavet.blogspot.com/
> Sun Certified Java Programmer
> ExpertsExchange Certified, Master:
> http://www.experts-exchange.com/M_1938796.html
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: a query for a special AND?

is_maximum
Hi Paul,
thanks, I dot your idea, now I am planing to implement this,
"de-normalization", now I just need your suggestion on this issue and tell
me which one is the best

I am considering to put a Field as follows:
my_de_normalized_field
service_name : service_value

if there are more than one service and value then I need to separate with a
character such as comma

service_name1:value1 , service_name2: value2,....

apart from that, each value might be a range value say, 10 - 20 or a single
value say, -2

do you have any suggestion on this?

thank you very much

On 9/20/07, Paul Elschot <[hidden email]> wrote:

>
> On Thursday 20 September 2007 09:19, Mohammad Norouzi wrote:
> > well, you mean we should separate documents just like relational tables
> in
> > databases ?
>
> Quite the contrary, it's called _de_normalization. This means that the
> documents in lucene normally contain more information than is present
> in a single relational entity.
>
> > if yes, how to make the relationship between those documents
>
> Lucene has no facilities to maintain relational relationships among
> its documents. A lucene index allows free format documents, i.e.
> any document may have any field or not.
> In practice you will need at least a primary key, but even that you will
> need to program yourself.
>
> Regards,
> Paul Elschot
>
>
>
> >
> > thank you so much Paul
> >
> > On 9/20/07, Paul Elschot <[hidden email]> wrote:
> > >
> > > On Thursday 20 September 2007 07:29, Mohammad Norouzi wrote:
> > > > Sorry Paul I just hurried in replying ;)
> > > > I read the documents of Lucene about query syntax and I figured out
> the
> > > what
> > > > is the difference
> > > > but my problem is different, this is preoccupied my mind and I am
> under
> > > > pressure to solve this problem, after analyzing the results I get,
> now I
> > > > think we need a "group by" in our query.
> > > >
> > > > let me tell you an example: we need a list of patients that have
> been
> > > > examined by certain services specified by the user , say service one
> and
> > > > service two.
> > > >
> > > > in this case here is the correct result:
> > > > patient-id              service_name               patient_result
> > > > 1                             s1                                12
> > > > 1                             s2                                13
> > > > 2                             s1                                  41
>
> > > > 2                             s2                                22
> > > >
> > > > but for example, following is incorrect because patient 1 has no
> service
> > > > with name service2:
> > > > patient-id              service_name               patient_result
> > > > 1                             s1                                12
> > > > 1                             s3                                13
> > >
> > > That depends on what you put in your lucene documents.
> > > You can only get complete lucene documents as query results.
> > > For the above example a patient with all service names
> > > should be indexed in a single lucene doc.
> > >
> > > The rows above suggest that the relation between patient and
> > > service forms the relational result. However, for a text search
> > > engine it is usual to denormalize the relational records into
> > > indexed documents, depending on the required output.
> > >
> > > Regards,
> > > Paul Elschot
> > >
> > >
> > >
> > > >
> > > >
> > > >
> > > > On 9/20/07, Mohammad Norouzi <[hidden email]> wrote:
> > > > >
> > > > > Hi Paul,
> > > > > would you tell me what is the difference between AND and + ?
> > > > > I tried both but get different result
> > > > > with AND I get 1777 documents and with + I get nearly 25000 ?
> > > > >
> > > > >
> > > > > On 9/17/07, Paul Elschot <[hidden email]> wrote:
> > > > > >
> > > > > > On Monday 17 September 2007 11:40, Mohammad Norouzi wrote:
> > > > > > > Hi
> > > > > > > I have a problem in getting correct result from Lucene,
> consider
> > > we
> > > > > > have an
> > > > > > > index containing documents with fields "field1" and "field2"
> etc.
> > > now
> > > > > > I want
> > > > > > > to have documents in which their field1 are equal one by one
> and
> > > their
> > > > > > > field2 with two different value
> > > > > > >
> > > > > > > to clarify consider I have this query:
> > > > > > > field1:val*  (field2:"myValue1" XOR field2:"myValue2")
> > > > > >
> > > > > > Did you try this:
> > > > > >
> > > > > > +field1:val*  +field2:"myValue1" +field2:"myValue2"
> > > > > >
> > > > > > Regards,
> > > > > > Paul Elschot
> > > > > >
> > > > > >
> > > > > > >
> > > > > > > now I want this result:
> > > > > > > field1              field2
> > > > > > > val1                myValue1
> > > > > > > val1                myValue2
> > > > > > > val2                myValue1
> > > > > > > val2                myValue2
> > > > > > >
> > > > > > > this result is not acceptable:
> > > > > > > val3              myValue1
> > > > > > > or
> > > > > > > val4             myValue1
> > > > > > > val4             myValue3
> > > > > > >
> > > > > > > I put XOR as operator because this is not a typical OR, it's
> > > > > > different, it
> > > > > > > means documents that contains both myValue1 and myValue2 for
> the
> > > field
> > > > > >
> > > > > > > field2
> > > > > > >
> > > > > > > how to build a query to get such result?
> > > > > > >
> > > > > > > thanks in advance
> > > > > > > --
> > > > > > > Regards,
> > > > > > > Mohammad
> > > > > > > --------------------------
> > > > > > > see my blog: http://brainable.blogspot.com/
> > > > > > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > > > > > Sun Certified Java Programmer
> > > > > > > ExpertsExchange Certified, Master:
> > > > > > > http://www.experts-exchange.com/M_1938796.html
> > > > > > >
> > > > > >
> > > > > >
> > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: [hidden email]
> > > > > > For additional commands, e-mail:
> [hidden email]
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Regards,
> > > > > Mohammad
> > > > > --------------------------
> > > > > see my blog: http://brainable.blogspot.com/
> > > > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > > > Sun Certified Java Programmer
> > > > > ExpertsExchange Certified, Master:
> > > http://www.experts-exchange.com/M_1938796.html
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Regards,
> > > > Mohammad
> > > > --------------------------
> > > > see my blog: http://brainable.blogspot.com/
> > > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > > Sun Certified Java Programmer
> > > > ExpertsExchange Certified, Master:
> > > > http://www.experts-exchange.com/M_1938796.html
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden email]
> > > For additional commands, e-mail: [hidden email]
> > >
> > >
> >
> >
> > --
> > Regards,
> > Mohammad
> > --------------------------
> > see my blog: http://brainable.blogspot.com/
> > another in Persian: http://fekre-motefavet.blogspot.com/
> > Sun Certified Java Programmer
> > ExpertsExchange Certified, Master:
> > http://www.experts-exchange.com/M_1938796.html
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
another in Persian: http://fekre-motefavet.blogspot.com/
Sun Certified Java Programmer
ExpertsExchange Certified, Master:
http://www.experts-exchange.com/M_1938796.html
--
Regards
Mohammad
Pixelshot
Reply | Threaded
Open this post in threaded view
|

Re: a query for a special AND?

Paul Elschot
As for suggestions on how to do this, I have no other than
to make sure that you can create the queries necessary to obtain
the required output.

Regards,
Paul Elschot


On Sunday 30 September 2007 09:20, Mohammad Norouzi wrote:

> Hi Paul,
> thanks, I dot your idea, now I am planing to implement this,
> "de-normalization", now I just need your suggestion on this issue and tell
> me which one is the best
>
> I am considering to put a Field as follows:
> my_de_normalized_field
> service_name : service_value
>
> if there are more than one service and value then I need to separate with a
> character such as comma
>
> service_name1:value1 , service_name2: value2,....
>
> apart from that, each value might be a range value say, 10 - 20 or a single
> value say, -2
>
> do you have any suggestion on this?
>
> thank you very much
>
> On 9/20/07, Paul Elschot <[hidden email]> wrote:
> > On Thursday 20 September 2007 09:19, Mohammad Norouzi wrote:
> > > well, you mean we should separate documents just like relational tables
> >
> > in
> >
> > > databases ?
> >
> > Quite the contrary, it's called _de_normalization. This means that the
> > documents in lucene normally contain more information than is present
> > in a single relational entity.
> >
> > > if yes, how to make the relationship between those documents
> >
> > Lucene has no facilities to maintain relational relationships among
> > its documents. A lucene index allows free format documents, i.e.
> > any document may have any field or not.
> > In practice you will need at least a primary key, but even that you will
> > need to program yourself.
> >
> > Regards,
> > Paul Elschot
> >
> > > thank you so much Paul
> > >
> > > On 9/20/07, Paul Elschot <[hidden email]> wrote:
> > > > On Thursday 20 September 2007 07:29, Mohammad Norouzi wrote:
> > > > > Sorry Paul I just hurried in replying ;)
> > > > > I read the documents of Lucene about query syntax and I figured out
> >
> > the
> >
> > > > what
> > > >
> > > > > is the difference
> > > > > but my problem is different, this is preoccupied my mind and I am
> >
> > under
> >
> > > > > pressure to solve this problem, after analyzing the results I get,
> >
> > now I
> >
> > > > > think we need a "group by" in our query.
> > > > >
> > > > > let me tell you an example: we need a list of patients that have
> >
> > been
> >
> > > > > examined by certain services specified by the user , say service
> > > > > one
> >
> > and
> >
> > > > > service two.
> > > > >
> > > > > in this case here is the correct result:
> > > > > patient-id              service_name               patient_result
> > > > > 1                             s1                                12
> > > > > 1                             s2                                13
> > > > > 2                             s1                                
> > > > > 41
> > > > >
> > > > > 2                             s2                                22
> > > > >
> > > > > but for example, following is incorrect because patient 1 has no
> >
> > service
> >
> > > > > with name service2:
> > > > > patient-id              service_name               patient_result
> > > > > 1                             s1                                12
> > > > > 1                             s3                                13
> > > >
> > > > That depends on what you put in your lucene documents.
> > > > You can only get complete lucene documents as query results.
> > > > For the above example a patient with all service names
> > > > should be indexed in a single lucene doc.
> > > >
> > > > The rows above suggest that the relation between patient and
> > > > service forms the relational result. However, for a text search
> > > > engine it is usual to denormalize the relational records into
> > > > indexed documents, depending on the required output.
> > > >
> > > > Regards,
> > > > Paul Elschot
> > > >
> > > > > On 9/20/07, Mohammad Norouzi <[hidden email]> wrote:
> > > > > > Hi Paul,
> > > > > > would you tell me what is the difference between AND and + ?
> > > > > > I tried both but get different result
> > > > > > with AND I get 1777 documents and with + I get nearly 25000 ?
> > > > > >
> > > > > > On 9/17/07, Paul Elschot <[hidden email]> wrote:
> > > > > > > On Monday 17 September 2007 11:40, Mohammad Norouzi wrote:
> > > > > > > > Hi
> > > > > > > > I have a problem in getting correct result from Lucene,
> >
> > consider
> >
> > > > we
> > > >
> > > > > > > have an
> > > > > > >
> > > > > > > > index containing documents with fields "field1" and "field2"
> >
> > etc.
> >
> > > > now
> > > >
> > > > > > > I want
> > > > > > >
> > > > > > > > to have documents in which their field1 are equal one by one
> >
> > and
> >
> > > > their
> > > >
> > > > > > > > field2 with two different value
> > > > > > > >
> > > > > > > > to clarify consider I have this query:
> > > > > > > > field1:val*  (field2:"myValue1" XOR field2:"myValue2")
> > > > > > >
> > > > > > > Did you try this:
> > > > > > >
> > > > > > > +field1:val*  +field2:"myValue1" +field2:"myValue2"
> > > > > > >
> > > > > > > Regards,
> > > > > > > Paul Elschot
> > > > > > >
> > > > > > > > now I want this result:
> > > > > > > > field1              field2
> > > > > > > > val1                myValue1
> > > > > > > > val1                myValue2
> > > > > > > > val2                myValue1
> > > > > > > > val2                myValue2
> > > > > > > >
> > > > > > > > this result is not acceptable:
> > > > > > > > val3              myValue1
> > > > > > > > or
> > > > > > > > val4             myValue1
> > > > > > > > val4             myValue3
> > > > > > > >
> > > > > > > > I put XOR as operator because this is not a typical OR, it's
> > > > > > >
> > > > > > > different, it
> > > > > > >
> > > > > > > > means documents that contains both myValue1 and myValue2 for
> >
> > the
> >
> > > > field
> > > >
> > > > > > > > field2
> > > > > > > >
> > > > > > > > how to build a query to get such result?
> > > > > > > >
> > > > > > > > thanks in advance
> > > > > > > > --
> > > > > > > > Regards,
> > > > > > > > Mohammad
> > > > > > > > --------------------------
> > > > > > > > see my blog: http://brainable.blogspot.com/
> > > > > > > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > > > > > > Sun Certified Java Programmer
> > > > > > > > ExpertsExchange Certified, Master:
> > > > > > > > http://www.experts-exchange.com/M_1938796.html
> > > >
> > > > ---------------------------------------------------------------------
> > > >
> > > > > > > To unsubscribe, e-mail: [hidden email]
> > > > > > > For additional commands, e-mail:
> >
> > [hidden email]
> >
> > > > > > --
> > > > > > Regards,
> > > > > > Mohammad
> > > > > > --------------------------
> > > > > > see my blog: http://brainable.blogspot.com/
> > > > > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > > > > Sun Certified Java Programmer
> > > > > > ExpertsExchange Certified, Master:
> > > >
> > > > http://www.experts-exchange.com/M_1938796.html
> > > >
> > > > > --
> > > > > Regards,
> > > > > Mohammad
> > > > > --------------------------
> > > > > see my blog: http://brainable.blogspot.com/
> > > > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > > > Sun Certified Java Programmer
> > > > > ExpertsExchange Certified, Master:
> > > > > http://www.experts-exchange.com/M_1938796.html
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [hidden email]
> > > > For additional commands, e-mail: [hidden email]
> > >
> > > --
> > > Regards,
> > > Mohammad
> > > --------------------------
> > > see my blog: http://brainable.blogspot.com/
> > > another in Persian: http://fekre-motefavet.blogspot.com/
> > > Sun Certified Java Programmer
> > > ExpertsExchange Certified, Master:
> > > http://www.experts-exchange.com/M_1938796.html
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]