You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by cju <ch...@utley.com> on 2014/03/10 00:23:15 UTC
Querying XML
I have some XML stored in Solr that looks like this:
<MainInfo>
<Info>
<Info name="Bob" city="Columbus" />
<Info name="Joe" city="Cincinnati" />
</Info>
</MainInfo>
What I’d like to do is get a hit for this document if there’s an element in
the XML where (@name=”Bob” AND @city=”Cincinnati”). If I write something
like this, I’ll get a hit – although I’m not actually matching what I’m
looking for:
q=MainData.Info.Info@name:Bob AND MainData.Info.Info@city:Cincinnati
I want to my criteria only to match attributes within the same element, for
example:
<MainData>
<Info>
<Info name="Bob" city="Columbus" />
<Info name="Joe" city="Cincinnati" />
<Info name="Bob" city="Cincinnati" /> (only match this)
</Info>
</MainData>
Is it possible to write a query to achieve this without changing my XML?
--
View this message in context: http://lucene.472066.n3.nabble.com/Querying-XML-tp4122451.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Querying XML
Posted by Michael Sokolov <ms...@safaribooksonline.com>.
Yes, Lux automatically indexes text in XML elements associated with
their element names so you can run efficient XPath/XQuery queries; in
your case I would write:
q=/MainData/Info/Info[@name="Bob"][city="Cincinnati"]
or
q=//Info[@name="Bob"][city="Cincinnati"]
It also let's you mix "regular" Solr queries with XPath, too
On 3/9/14 8:16 PM, Alexandre Rafalovitch wrote:
> Are you using or have you looked at http://luxdb.org/ ? Might be relevant.
>
> Regards,
> Alex.
> Personal website: http://www.outerthoughts.com/
> LinkedIn: http://www.linkedin.com/in/alexandrerafalovitch
> - Time is the quality of nature that keeps events from happening all
> at once. Lately, it doesn't seem to be working. (Anonymous - via GTD
> book)
>
>
> On Mon, Mar 10, 2014 at 6:23 AM, cju <ch...@utley.com> wrote:
>> I have some XML stored in Solr that looks like this:
>>
>> <MainInfo>
>> <Info>
>> <Info name="Bob" city="Columbus" />
>> <Info name="Joe" city="Cincinnati" />
>> </Info>
>> </MainInfo>
>>
>> What I’d like to do is get a hit for this document if there’s an element in
>> the XML where (@name=”Bob” AND @city=”Cincinnati”). If I write something
>> like this, I’ll get a hit – although I’m not actually matching what I’m
>> looking for:
>>
>> q=MainData.Info.Info@name:Bob AND MainData.Info.Info@city:Cincinnati
>>
>> I want to my criteria only to match attributes within the same element, for
>> example:
>>
>> <MainData>
>> <Info>
>> <Info name="Bob" city="Columbus" />
>> <Info name="Joe" city="Cincinnati" />
>> <Info name="Bob" city="Cincinnati" /> (only match this)
>> </Info>
>> </MainData>
>>
>> Is it possible to write a query to achieve this without changing my XML?
>>
>>
>>
>> --
>> View this message in context: http://lucene.472066.n3.nabble.com/Querying-XML-tp4122451.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
Re: Querying XML
Posted by Alexandre Rafalovitch <ar...@gmail.com>.
Are you using or have you looked at http://luxdb.org/ ? Might be relevant.
Regards,
Alex.
Personal website: http://www.outerthoughts.com/
LinkedIn: http://www.linkedin.com/in/alexandrerafalovitch
- Time is the quality of nature that keeps events from happening all
at once. Lately, it doesn't seem to be working. (Anonymous - via GTD
book)
On Mon, Mar 10, 2014 at 6:23 AM, cju <ch...@utley.com> wrote:
> I have some XML stored in Solr that looks like this:
>
> <MainInfo>
> <Info>
> <Info name="Bob" city="Columbus" />
> <Info name="Joe" city="Cincinnati" />
> </Info>
> </MainInfo>
>
> What I’d like to do is get a hit for this document if there’s an element in
> the XML where (@name=”Bob” AND @city=”Cincinnati”). If I write something
> like this, I’ll get a hit – although I’m not actually matching what I’m
> looking for:
>
> q=MainData.Info.Info@name:Bob AND MainData.Info.Info@city:Cincinnati
>
> I want to my criteria only to match attributes within the same element, for
> example:
>
> <MainData>
> <Info>
> <Info name="Bob" city="Columbus" />
> <Info name="Joe" city="Cincinnati" />
> <Info name="Bob" city="Cincinnati" /> (only match this)
> </Info>
> </MainData>
>
> Is it possible to write a query to achieve this without changing my XML?
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Querying-XML-tp4122451.html
> Sent from the Solr - User mailing list archive at Nabble.com.