Beispiel #1
0
 public ValidationResult Validate(SolrFieldType solrFieldType, string propertyName, Type propertyType)
 {
     if (new[] { "solr.TextField", "solr.StrField" }.Any(st => st == solrFieldType.Type))
     {
         return(new ValidationWarning(String.Format("Property '{0}' of type '{1}' is mapped to a solr field of type '{2}'. These types are not fully compatible. You won't be able to use this field for range queries.", propertyName, propertyType.FullName, solrFieldType.Name)));
     }
     if (new[] { "FloatField", "DoubleField" }.Any(st => Regex.IsMatch(solrFieldType.Type, st)))
     {
         return(new ValidationWarning(String.Format("Property '{0}' of type '{1}' is mapped to a solr field of type '{2}'. These types are not fully compatible. You might lose precision or get OverflowExceptions", propertyName, propertyType.FullName, solrFieldType.Name)));
     }
     return(new ValidationError(String.Format("Property '{0}' of type '{1}' cannot be stored in solr field type '{2}'.", propertyName, propertyType.FullName, solrFieldType.Name)));
 }
        public void DictionaryFields_are_ignored()
        {
            var rule   = new MappedPropertiesIsInSolrSchemaRule();
            var mapper = new MappingManager();

            mapper.Add(typeof(SchemaMappingTestDocument).GetProperty("DynamicMapped"), "ma_*");
            var schema    = new SolrSchema();
            var fieldType = new SolrFieldType("string", "solr.StrField");

            schema.SolrFields.Add(new SolrField("ma_uaua", fieldType));
            var results = rule.Validate(typeof(SchemaMappingTestDocument), new SolrSchema(), mapper).ToList();

            Assert.Empty(results);
        }
Beispiel #3
0
        /// <inheritdoc/>
        public virtual ValidationResult Validate(SolrFieldType solrFieldType, string propertyName, Type propertyType)
        {
            // Check if the type is in the safe or warning types and otherwise return a error
            if (safeTypes != null && safeTypes.Contains(solrFieldType.Type))
            {
                return(null);
            }
            if (warningTypes != null && warningTypes.Contains(solrFieldType.Type))
            {
                return(new ValidationWarning(String.Format("Property '{0}' of type '{1}' is mapped to a solr field of type '{2}'. These types are not fully compatible.", propertyName, propertyType.FullName, solrFieldType.Name)));
            }

            return(new ValidationError(String.Format("Property '{0}' of type '{1}' cannot be stored in solr field type '{2}'.", propertyName, propertyType.FullName, solrFieldType.Name)));
        }
        private XElement GetReplaceTextGeneralFieldType()
        {
            SolrFieldType solrFieldType =
                this.solrSchema.SolrFieldTypes.Find((Predicate <SolrFieldType>)(f => f.Name == "text_general"));

            if (solrFieldType == null)
            {
                return((XElement)null);
            }
            XElement xelement1 = new XElement((XName)"replace-field-type");

            xelement1.Add((object)new XElement((XName)"name", (object)solrFieldType.Name));
            xelement1.Add((object)new XElement((XName)"class", (object)solrFieldType.Type));
            xelement1.Add((object)new XElement((XName)"positionIncrementGap", (object)"100"));
            xelement1.Add((object)new XElement((XName)"multiValued", (object)"false"));
            XElement xelement2 = new XElement((XName)"indexAnalyzer");

            xelement2.Add(
                (object)new XElement(
                    (XName)"tokenizer",
                    (object)new XElement((XName)"class", (object)"solr.StandardTokenizerFactory")));
            xelement2.Add(
                (object)new XElement(
                    (XName)"filters",
                    new object[3]
            {
                (object)new XElement((XName)"class", (object)"solr.StopFilterFactory"),
                (object)new XElement((XName)"ignoreCase", (object)"true"),
                (object)new XElement((XName)"words", (object)"stopwords.txt")
            }));
            xelement2.Add(
                (object)new XElement(
                    (XName)"filters",
                    (object)new XElement((XName)"class", (object)"solr.LowerCaseFilterFactory")));
            xelement1.Add((object)xelement2);
            XElement xelement3 = new XElement((XName)"queryAnalyzer");

            xelement3.Add(
                (object)new XElement(
                    (XName)"tokenizer",
                    (object)new XElement((XName)"class", (object)"solr.StandardTokenizerFactory")));
            xelement3.Add(
                (object)new XElement(
                    (XName)"filters",
                    new object[3]
            {
                (object)new XElement((XName)"class", (object)"solr.StopFilterFactory"),
                (object)new XElement((XName)"ignoreCase", (object)"true"),
                (object)new XElement((XName)"words", (object)"stopwords.txt")
            }));

            /*xelement3.Add(
             *  (object)new XElement(
             *      (XName)"filters",
             *      new object[4]
             *      {
             *          (object)new XElement((XName)"class", (object)"solr.SynonymFilterFactory"),
             *          (object)new XElement((XName)"synonyms", (object)"synonyms.txt"),
             *          (object)new XElement((XName)"ignoreCase", (object)"true"),
             *          (object)new XElement((XName)"expand", (object)"true")
             *      }));*/

            // Remove hardcoded synonyms from file& and filters. Added custom pipeline instead.
            xelement3.Add(new XElement("filters",
                                       new XElement("class", "solr.ManagedSynonymGraphFilterFactory"),
                                       new XElement("managed", "english")));

            xelement3.Add(
                (object)new XElement(
                    (XName)"filters",
                    (object)new XElement((XName)"class", (object)"solr.LowerCaseFilterFactory")));
            xelement1.Add((object)xelement3);
            return(xelement1);
        }