[ https://issues.apache.org/jira/browse/SOLR-10218?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steve Rowe updated SOLR-10218: ------------------------------ Fix Version/s: master (7.0) 6.5 > The Schema API commands "add-field-type" and "replace-field-type" improperly > specify SimilarityFactory params > ------------------------------------------------------------------------------------------------------------- > > Key: SOLR-10218 > URL: https://issues.apache.org/jira/browse/SOLR-10218 > Project: Solr > Issue Type: Bug > Security Level: Public(Default Security Level. Issues are Public) > Components: Schema and Analysis > Affects Versions: 6.4.1 > Reporter: Benjamin Deininger > Assignee: Steve Rowe > Priority: Minor > Fix For: 6.5, master (7.0) > > Attachments: SOLR-10218.patch, SOLR-10218.patch > > > When sending a JSON POST to the Schema API to replace a field type, the > following JSON does not pass the SolrParameters properly to the > BM25SimilarityFactory. > {code:javascript} > {"replace-field-type":{"name":"tint","class":"solr.TrieIntField","positionIncrementGap":"0","precisionStep":"8","similarity":{"class":"solr.BM25SimilarityFactory","k1":1.25,"b":0.75}}} > {code} > The `appendAttrs` function in the FieldTypeXmlAdapter parses k1 and b into > attributes instead of children. > https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/rest/schema/FieldTypeXmlAdapter.java#L155 > {code:xml} > <similarity b="0.75" > class="org.apache.lucene.search.similarities.BM25Similarity" k1="1.25"/> > {code} > Based on the XML examples for similarity, this should actually be the > following : > {code:xml} > <similarity class="org.apache.lucene.search.similarities.BM25Similarity"> > <float name=“k1”>0.1</float> > <float name=“b”>0.1</float> > </similarity> > {code} > The similarities block in JSON should be handled differently so that the XML > is generated appropriately. > {code:java} > protected static Element appendSimilarityAttrs(Document doc, Element elm, > Map<String,?> json) { > String clazz = (String) json.get("class"); > elm.setAttribute("class", clazz); > json.remove("class"); > for (Map.Entry<String,?> entry : json.entrySet()) { > Object val = entry.getValue(); > if (val != null && !(val instanceof Map)) { > Element element = > doc.createElement(val.getClass().getSimpleName().toLowerCase()); > element.setAttribute("name", entry.getKey()); > element.setTextContent(entry.getValue().toString()); > elm.appendChild(element); > } > } > return elm; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org