Return-Path: X-Original-To: apmail-lucene-solr-commits-archive@minotaur.apache.org Delivered-To: apmail-lucene-solr-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E48CF9825 for ; Thu, 8 Mar 2012 23:13:14 +0000 (UTC) Received: (qmail 73741 invoked by uid 500); 8 Mar 2012 23:13:14 -0000 Delivered-To: apmail-lucene-solr-commits-archive@lucene.apache.org Received: (qmail 73707 invoked by uid 500); 8 Mar 2012 23:13:14 -0000 Mailing-List: contact solr-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-dev@lucene.apache.org Delivered-To: mailing list solr-commits@lucene.apache.org Received: (qmail 73691 invoked by uid 99); 8 Mar 2012 23:13:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Mar 2012 23:13:14 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.131] (HELO eos.apache.org) (140.211.11.131) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Mar 2012 23:13:11 +0000 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id 78BF2361; Thu, 8 Mar 2012 23:12:50 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Apache Wiki To: Apache Wiki Date: Thu, 08 Mar 2012 23:12:50 -0000 Message-ID: <20120308231250.98765.63114@eos.apache.org> Subject: =?utf-8?q?=5BSolr_Wiki=5D_Update_of_=22MoneyFieldType=22_by_JanHoydahl?= Auto-Submitted: auto-generated X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Solr Wiki" for chan= ge notification. The "MoneyFieldType" page has been changed by JanHoydahl: http://wiki.apache.org/solr/MoneyFieldType?action=3Ddiff&rev1=3D10&rev2=3D11 - Work in progress at [[https://issues.apache.org/jira/browse/SOLR-2202= |SOLR-2202]] + Moved. Please see CurrencyField = - The MoneyFieldType was created by Greg Fodor in [[https://issues.apache.o= rg/jira/browse/SOLR-2202|SOLR-2202]], and is an advanced poly field type in= dexing a monetary value as both value and currency. It lets e.g. an e-comme= rce site to display and query prices in many currencies, while only indexin= g the price in one field/currency. - = - The field type is backed by an XML file {{{currency.xml}}} specifying exc= hange rates. This file may be updated without need for reindexing, and a re= load-core will set live the updated exchange rates. - = - =3D=3D=3D Configuration =3D=3D=3D - See example schema for example of how to use the field type. The field ty= pe and field is defined in schema.xml as follows: - {{{ - - = - - }}} - = - !DefaultCurrency will be used if you do not specify a currency. The defau= lt defaultCurrency is {{{USD}}}, if not specified. Note that defaultCurrenc= y cannot be changed unless followed by a full re-index. - = - You then need to point to a {{{currency.xml}}} file specifying the exchan= ge rates: - = - {{{ - - - - - = - - - - - = - - - - - }}} - = - Note that you need a rate entry between every two pairs of currencies you= will index or query. So if you handle USD, EUR and GBP, you need USD->EUR,= USD->GBP and EUR->GBP, so that all possible conversions can be done. If yo= u only index one currency (say USD) but want to query or convert multiple, = it is enough to have rates between USD and all currencies you'll query or d= isplay. - = - By default the rate will be symmetrical, but you may override this by exp= licitly specifying the reverse rate. - = - !MoneyFieldType supports replication, given that you explicitly configure= replication for {{{currency.xml}}}. Upon the arrival of a new version of c= urrency.xml, Solr slaves will do a core reload and begin using the new exch= ange rates. See [[SolrReplication#How_are_configuration_files_replicated.3F= |SolrReplication]] for more. - = - =3D=3D=3D Indexing =3D=3D=3D - When you index e.g. a price, you specify value and currency separated by = comma: - {{{ - - 1 - 1.00,USD - - }}} - = - Here, 1.00,USD is assumed to mean $1.00. Note that regardless of the curr= ency being indexed, you must encode the value as a floating point value (wi= th a decimal point.) The fractional portion of the floating point value is = interpreted based upon the currency, via Currency.getDefaultFractionDigits(= ). - = - = - =3D=3D=3D Querying =3D=3D=3D - The !MoneyFieldType supports both point queries and range queries. Here a= re some valid money queries. Assume default currency is {{{EUR}}}: - {{{ - price:25.00,EUR or price:25.00 Both of thes= e will query for =E2=82=AC25.00 = - price:[* TO 10.00,EUR] or price:[* TO 10.00] - price:[10.00,USD TO 100.00,USD] Meaning betw= een $10.00 and $100.00 - price:10.00,NOK - }}} - = - =3D=3D=3D Usage =3D=3D=3D - = - Solr documents will always yield the currency values they were indexed wi= th, regardless of how they were queried for. For example, a set of document= s indexed in USD will yield USD values for its Money fields regardless if y= ou performed queries in EUR. = - = - So, for the display of Money fields to a user, it is often necessary to p= erform a second currency conversion once the documents are returned for dis= play purposes. For accuracy, this conversion should apply the same exchange= rates in the currency.xml file available to Solr. - = - =3D=3D TODO =3D=3D - = - * facet.range does not work with this field type - this should be fixed -=20