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 Gustavo <g....@gmail.com> on 2009/12/22 21:36:29 UTC

query ( dynamicField ) in solr

Hello All,

 I have been trying to make a query at a dynamicField.
for example:
i have a product that can have many sku's. So at my xsd i have
<dynamicField name="sku_externalId_*" type="text" indexed="true"
stored="true" />
<dynamicField name="sku_defaultPrice_*" type="text" indexed="true"
stored="true" />
                                                    .
                                                    .
                                                    .
when a make a query:
http://localhost:8983/solr/productIdx/select/?q=sku_defaultPrice_2:valueOfThePrice
or
http://localhost:8983/solr/productIdx/select/?q=sku_defaultPrice_1:valueOfThePriceor
sku_defaultPrice_2:valueOfThePrice or
sku_defaultPrice_3:valueOfThePrice
it works !!

but i can have many sku_defaultPrice_*
but i have no idea in how to make the query with this kind of field
thanks for helping

-- 
-- 
Atenciosamente,

Gustavo de Araujo Lima Machado
Telefone: +55 +21 ***********
Celular: +55+21 99034401
E-Mail: g.machado1@gmail.com.br

Residência
:

Re: query ( dynamicField ) in solr

Posted by Rob Casson <ro...@gmail.com>.
sounds like a job for copyField:

     http://wiki.apache.org/solr/FAQ#How_do_I_use_copyField_with_wildcards.3F

add sku_defaultPriceAll to your <fields> and then:

    <copyField source="sku_defaultPrice_*"  dest="sku_defaultPriceAll" />

...query on sku_defaultPriceAll.

hth,
rob

On Tue, Dec 22, 2009 at 3:36 PM, Gustavo <g....@gmail.com> wrote:
> Hello All,
>
>  I have been trying to make a query at a dynamicField.
> for example:
> i have a product that can have many sku's. So at my xsd i have
> <dynamicField name="sku_externalId_*" type="text" indexed="true"
> stored="true" />
> <dynamicField name="sku_defaultPrice_*" type="text" indexed="true"
> stored="true" />
>                                                    .
>                                                    .
>                                                    .
> when a make a query:
> http://localhost:8983/solr/productIdx/select/?q=sku_defaultPrice_2:valueOfThePrice
> or
> http://localhost:8983/solr/productIdx/select/?q=sku_defaultPrice_1:valueOfThePriceor
> sku_defaultPrice_2:valueOfThePrice or
> sku_defaultPrice_3:valueOfThePrice
> it works !!
>
> but i can have many sku_defaultPrice_*
> but i have no idea in how to make the query with this kind of field
> thanks for helping
>
> --
> --
> Atenciosamente,
>
> Gustavo de Araujo Lima Machado
> Telefone: +55 +21 ***********
> Celular: +55+21 99034401
> E-Mail: g.machado1@gmail.com.br
>
> Residência
> :
>

Re: query ( dynamicField ) in solr

Posted by AHMET ARSLAN <io...@yahoo.com>.
>  I have been trying to make a query at a dynamicField.
> for example:
> i have a product that can have many sku's. So at my xsd i
> have
> <dynamicField name="sku_externalId_*" type="text"
> indexed="true"
> stored="true" />
> <dynamicField name="sku_defaultPrice_*" type="text"
> indexed="true"
> stored="true" />
>                
> when a make a query:
> http://localhost:8983/solr/productIdx/select/?q=sku_defaultPrice_2:valueOfThePrice
> or
> http://localhost:8983/solr/productIdx/select/?q=sku_defaultPrice_1:valueOfThePriceor
> sku_defaultPrice_2:valueOfThePrice or
> sku_defaultPrice_3:valueOfThePrice
> it works !!
> 
> but i can have many sku_defaultPrice_*
> but i have no idea in how to make the query with this kind
> of field
> thanks for helping
> 

So you want to query all fields of a dynamic field. I am not sure how to do that automatically but you can dynamically get those field names from :
http://localhost:8983/solr/productIdx/admin/luke?numTerms=0
 
"/response/lst[@name='fields']/lst/str[@name='dynamicBase'][.='sku_defaultPrice_*'

and then construct your query. Hope this helps.